Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 618
  • Last Modified:

C# xml path writer

I want to create an XML document like this:

<node1>
  <node2>
    <node3>some text</node3>
  </node2>
</node1>

Code I've seen that does this must call CreateElement() on an XmlDocument for each node. Is there a function that you can pass the entire node path to, and the final text node will be created, like this?

XmlCreateTextNode("node1/node2/node3", "some text");

I could always write such a function from scratch, but I'll bet such a function exists which is better than what I would write.
0
bmihura
Asked:
bmihura
1 Solution
 
anarki_jimbelCommented:
I don't want to reinvent a wheel. You can use XPath for the task. Try:

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XML/Q_20897931.html
0
 
bmihuraAuthor Commented:
I still have to manually create the branch XML elements, but that code got me most of the way there, much better than I would have written it.  Thanks.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now