xUlliaelhilbr
New Member
I have got a big trouble in my Xml generator using C#.I could not find how to add a parent node containing the element's name.The information is coming from a database and inserted into the Xml document in memory.I have to get those nodes by name because I will need to convert some of them.Code:\[code\]XmlElement xe = xd.CreateElement("xe");foreach (XmlNode node in xd.DocumentElement.ChildNodes){ XmlNode imported = xd.ImportNode(node, true); xe.AppendChild(imported["a"]); xe.AppendChild(imported["b"]); xe.AppendChild(imported["c"]); xe.AppendChild(imported["d"]);}\[/code\]Result:\[code\] <node> <a>1</a> <b>2</b> <c>3</c> <d>4</d> <a>1</a> <b>2</b> <c>3</c> <d>4</d> <a>1</a> <b>2</b> <c>3</c> <d>4</d> </node>\[/code\]What I need:\[code\] <node> <ex> <a>1</a> <b>2</b> <c>3</c> <d>4</d> </ex> <ex> <a>1</a> <b>2</b> <c>3</c> <d>4</d> </ex> <ex> <a>1</a> <b>2</b> <c>3</c> <d>4</d> </ex> </node>\[/code\]