C#XML将子节点名称与父节点名称和值合并

C#XML将子节点名称与父节点名称和值合并,c#,xml,C#,Xml,我希望将父节点的名称与子节点的名称合并,以使所有节点都处于顶层。我甚至不知道从哪里开始写代码。我用的是C#。我希望从合并进程中排除根节点 Example before: <root> <lastname>string</lastname> <firstname>string</firstname> <student> <id>string<

我希望将父节点的名称与子节点的名称合并,以使所有节点都处于顶层。我甚至不知道从哪里开始写代码。我用的是C#。我希望从合并进程中排除根节点

Example before:
    <root>
       <lastname>string</lastname>
       <firstname>string</firstname>
       <student>
          <id>string</id>
          <ssn>string</ssn>
       </student>
    </root>

XML after:
    <root>
       <lastname>string</lastname>
       <firstname>string</firstname>
       <studentid>string</studentid>
       <studentssn>string</studentssn>
    </root>
前面的示例:
一串
一串
一串
一串
XML之后:
一串
一串
一串
一串

因此,学生家长已与id和ssn合并。如果这是可能的,我们将非常感谢您的帮助。

还需要一些约束,否则您将获得一组节点
…)我在描述中加了一条说明。谢谢,相信这是可能的。但方法取决于你拥有的工具。是否要使用表示法?您是否使用带有XML解析器和序列化程序的库?您打算用XQuery处理XML吗?或者您想自己从头开始编写XML解释器和构建器。。。?您还可以使用标准的Linux命令行文本操作工具,如
awk
,或者甚至可以使用
sed