How do I add a namespace to only ref elements in C#?

Digneasetrisa

New Member
I have an XElement which contains the content that I want. However, I want to add a namespace prefix to only the ref elements. Is this possible in C#?For example, the original XML looks like this:\[code\]<Root> <Element1 /> <Element2 /> <Element3> <Element3_Child1 /> <Element3_Child2 /> </Element3> <Element4 /> <Element5> <Element5_Child1> <Element5_Child1_Child51 /> </Element5_Child1> </Element5></Root>\[/code\]I want to add a namespace prefix, so that the XML looks as below\[code\]<Root> <Element1 /> <Element2 /> <ns:Element3> <Element3_Child1 /> <Element3_Child2 /> </Element3> <Element4 /> <ns:Element5> <ns:Element5_Child1> <Element5_Child1_Child51 /> </Element5_Child1> </Element5></Root>\[/code\]
 
Back
Top