I have a string containing some XML:
<some>
<xml></xml>
<tags/>
<TheData/>
<more>asdf</more>
<of/>
<them></them>
</some>
Instead of <TheData/>
we could have <TheData></TheData>
or other equivalent forms.
Questions:
1: How can I make sure that the XML does indeed contain an empty TheData
element?
2: How can I insert another XML string, HTML encoded into TheData
? Example of the other XML:
<mydata>
<name>John</name>
<address>New York City</address>
</mydata>
End result:
<some>
<xml></xml>
<tags/>
<TheData>
<mydata>
<name>John</name>
<address>New York City</address>
</mydata>
</TheData>
<more>asdf</more>
<of/>
<them></them>
</some>
Are there quick ways to do this with e.g. LINQ to XML?