471,344 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,344 software developers and data experts.

Is it possible to get an XDocument from an XmlNode?

I searched a little, and saw a few people who also wanna do this, but
I haven't found a solution.

Thank you.
Jun 27 '08 #1
5 7142
Untested, but how about:

XmlNode node;// TODO
XDocument doc = XDocument.Load(new XmlNodeReader(node));
Jun 27 '08 #2
you can use OwnerDocument attribute of XMLNode class...

-ArunDhaJ
Jun 27 '08 #3
On Jun 4, 3:39 pm, ArunDhaJ <arund...@gmail.comwrote:
you can use OwnerDocument attribute of XMLNode class...

-ArunDhaJ
Thank you, but I think OwnerDocument property returns an XmlDocument
instead of XDocument. I explicitly want XDocument, not XmlDocument.
Jun 27 '08 #4
On Jun 4, 3:33 pm, Marc Gravell <marc.grav...@gmail.comwrote:
Untested, but how about:

XmlNode node;// TODO
XDocument doc = XDocument.Load(new XmlNodeReader(node));
That may work since XmlNodeReader is an XmlReader and the XDocument's
Load method does take an XmlReader argument. I need to give it a
shot. Thank you.
Jun 27 '08 #5
On Jun 4, 3:33 pm, Marc Gravell <marc.grav...@gmail.comwrote:
Untested, but how about:

XmlNode node;// TODO
XDocument doc = XDocument.Load(new XmlNodeReader(node));
Just tested it, it works like a charm. Thanks a lot.
Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mahesh Devjibhai Dhola | last post: by
2 posts views Thread by J Mon | last post: by
5 posts views Thread by Paul | last post: by
5 posts views Thread by Mahesh Devjibhai Dhola | last post: by
7 posts views Thread by Buddy Ackerman | last post: by
2 posts views Thread by =?Utf-8?B?c29uaWNt?= | last post: by
3 posts views Thread by Tom | last post: by
reply views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.