Connecting Tech Pros Worldwide Help | Site Map

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

Member
 
Join Date: Oct 2008
Posts: 42
#1: Oct 31 '08
hi all...
can any one help me by suggesting a way to convert an object of type "xmlnode" to an object of type "xmltextreader"...
markmcgookin's Avatar
Moderator
 
Join Date: Dec 2006
Location: Northern Ireland / England
Posts: 546
#2: Oct 31 '08

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


Quote:

Originally Posted by libish

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.
Member
 
Join Date: Oct 2008
Posts: 42
#3: Nov 3 '08

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


Quote:

Originally Posted by markmcgookin

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..
markmcgookin's Avatar
Moderator
 
Join Date: Dec 2006
Location: Northern Ireland / England
Posts: 546
#4: Nov 3 '08

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


Quote:

Originally Posted by libish

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?
Member
 
Join Date: Oct 2008
Posts: 42
#5: Nov 3 '08

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


Quote:

Originally Posted by markmcgookin

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...
Moderator
 
Join Date: Mar 2006
Posts: 1,103
#6: Nov 4 '08

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


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
Member
 
Join Date: Oct 2008
Posts: 42
#7: Nov 5 '08

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


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..
markmcgookin's Avatar
Moderator
 
Join Date: Dec 2006
Location: Northern Ireland / England
Posts: 546
#8: Nov 5 '08

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


Quote:

Originally Posted by libish

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?
Moderator
 
Join Date: Mar 2006
Posts: 1,103
#9: Nov 6 '08

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


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.
Member
 
Join Date: Oct 2008
Posts: 42
#10: Nov 7 '08

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


that works.. thank you so much..
Reply