We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

C# xml path writer

bmihura
bmihura asked
on
Medium Priority
634 Views
Last Modified: 2012-05-06
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.
Comment
Watch Question

Senior Developer
CERTIFIED EXPERT
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.