472,127 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

can any one help, xml node to xmltextreader...

42
hi all...
can any one help me by suggesting a way to convert an object of type "xmlnode" to an object of type "xmltextreader"...
Oct 31 '08 #1
9 4069
markmcgookin
648 Expert 512MB
hi all...
can any one help me by suggesting a way to convert an object of type "xmlnode" to an object of type "xmltextreader"...
You would need to create an xmldocument containing the xml node and read it in to the mxltextreader... but why would you need to do this? if you have an xmlnode object you can read directly from it.
Oct 31 '08 #2
libish
42
You would need to create an xmldocument containing the xml node and read it in to the mxltextreader... but why would you need to do this? if you have an xmlnode object you can read directly from it.

yes i have made an xmldoc object from xmlnode object .. but i couldnt find any overloading method fo xmltextreader that accepts an xmldoc object as its input...

why i need to do like this is that... i need to manipulate an xml file.. some methods are available only in xmldo.. and other methods are available only in xmltextreader method..
Nov 3 '08 #3
markmcgookin
648 Expert 512MB
yes i have made an xmldoc object from xmlnode object .. but i couldnt find any overloading method fo xmltextreader that accepts an xmldoc object as its input...

why i need to do like this is that... i need to manipulate an xml file.. some methods are available only in xmldo.. and other methods are available only in xmltextreader method..
Can you be more specific in what you are trying to do?
Nov 3 '08 #4
libish
42
Can you be more specific in what you are trying to do?
here, i need to move to a particular node.. so i used xmldocument class
again from that node i need to pic an attribute value corresponding to a particular attribute name... for this i'm using xmltextreader class object.

now what i'm doing is, i am selecting a node using xmldocument class object.. and i'm converting that node into an xmldoc object and saving it into an xml file...
now i'm loading the saved xml file into an xmltextreader class object and picking the attribute value by using one of the method provided by xmltextreader class...
Nov 3 '08 #5
jkmyoung
2,057 Expert 2GB
It really sounds like you're over complicating things by using the xmlTextReader. Is there any reason you couldn't get the attribute value by using the XMLDocument's SelectNodes(xpath) or SelectSingleNode(xpath) functions?
http://msdn.microsoft.com/en-us/libr...t_members.aspx
Nov 4 '08 #6
libish
42
ok SelectNodes(xpath) or SelectSingleNode(xpath) functions are used to select nodes....
that i'm using.. after selecting a single node.. i need to pic an attribute value by telling its name..
suppose 3 attributes are there in a node, the names are a,b&c..
here i need the value of attribute "a".. here to pic attribute value using attribute name ,there is a method in xmltextreader... so i want to change the type of object here... this is where i need help..
Nov 5 '08 #7
markmcgookin
648 Expert 512MB
ok SelectNodes(xpath) or SelectSingleNode(xpath) functions are used to select nodes....
that i'm using.. after selecting a single node.. i need to pic an attribute value by telling its name..
suppose 3 attributes are there in a node, the names are a,b&c..
here i need the value of attribute "a".. here to pic attribute value using attribute name ,there is a method in xmltextreader... so i want to change the type of object here... this is where i need help..
If you declare an xmlnode object with your selected node in it you can just use getAttribute("attributeName");

Style methods... are you able to post some of your code for us to look at?
Nov 5 '08 #8
jkmyoung
2,057 Expert 2GB
You can still use selectSingleNode to get the attribute. Use @ in the xpath.

eg if your xml was:
Expand|Select|Wrap|Line Numbers
  1. <root>
  2.   <parent>
  3.       <child a="agad" b="beez" c="cinn"/>
  4.   </parent>
  5. </root>
  6.  
You could use selectSingleNode("/root/parent/child/@a")
to get the a attribute.
Nov 6 '08 #9
libish
42
that works.. thank you so much..
Nov 7 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by juli jul | last post: by
1 post views Thread by Chua Wen Ching | last post: by
2 posts views Thread by Richard | last post: by
2 posts views Thread by phangmo | last post: by
4 posts views Thread by CodeRazor | last post: by
2 posts views Thread by David Thielen | last post: by
reply views Thread by fredrik | 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.