C# xml path writer

I want to create an XML document like this:

    <node3>some text</node3>

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.
Who is Participating?
I don't want to reinvent a wheel. You can use XPath for the task. Try:

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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.