如何在 XML 文档中围绕一组相同的 xml 标签插入结束和结束标签?例如,如果我的原始 XML 如下所示:
<recordImport OperatorID="ABC123">
<patients>
<patient roomNo=1 name="George Washington" addressID="1">
<address ID="1" street="123 Credibility Street" city="Boston" state="MA"/>
<address ID="1" street="456 Aqualung Avenue" city="Seattle" state="WA"/>
</patient>
<patient roomNo=2 name="Thomas Jefferson" addressID="2">
<address ID="2" street="5 Famous Street" city="Burbank" state="CA"/>
</patient>
</patients>
</recordImport>
我如何插入“地址”标签,如下所示:
<recordImport OperatorID="ABC123">
<patients>
<patient roomNo=1 name="George Washington" addressID="1">
<addresses>
<address ID="1" street="123 Credibility Street" city="Boston" state="MA"/>
<address ID="1" street="456 Aqualung Avenue" city="Seattle" state="WA"/>
</addresses>
</patient>
<patient roomNo=2 name="Thomas Jefferson" addressID="2">
<addresses>
<address ID="2" street="5 Famous Street" city="Burbank" state="CA"/>
</addresses>
</patient>
</patients>
</recordImport>
我更喜欢非 LINQ 解决方案,但如果归根结底,我会使用它。
提前致谢。