从xml文件中获取特定标记,并使用xml [duplicate]以xml格式返回它们

This question already has an answer here:

assume I have simple xml like this one, and I want to read it in way that I will get the element in xml format.

<?xml version="1.0" encoding="UTF-8"?>
    <contentdata>
        <Games>
        <numberof>2</numberof>
            <nameof>
                <n1>Game1</n1>
                <n2>Game2</n2>
            </nameof>
         </Games>
         <Software>
        <numberof>1</numberof>
            <nameof>
                <n1>Software1</n1>
            </nameof>
         </Software>
    </contentdata>

That means the output after reading should be like below :- Kindly, assist in any way you can, I will appreciate that. Thank you.

          <Games>
              <numberof>2</numberof>
                <nameof>
                    <n1>Game1</n1>
                    <n2>Game2</n2>
                </nameof>
             </Games>
</div>