473,473 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

42 New Member
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 4259
markmcgookin
648 Recognized Expert Contributor
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 New Member
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 Recognized Expert Contributor
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 New Member
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 Recognized Expert Top Contributor
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 New Member
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 Recognized Expert Contributor
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 Recognized Expert Top Contributor
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 New Member
that works.. thank you so much..
Nov 7 '08 #10

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

Similar topics

6
by: David B. Bitton | last post by:
I am having a problem deserializing XML when the root node is missing a namespace declaration. My Type has an XmlTypeAttribute with a namespace defined. If I attempt to deserialize the XML, I get...
5
by: juli jul | last post by:
Hello, How can I get a xml node from a XmlTextReader? Thanks a lot! *** Sent via Developersdex http://www.developersdex.com ***
1
by: Chua Wen Ching | last post by:
Hi there, I have some problems when reading XML file. 1. First this, is what i did, cause i can't seem to read "sub elements or tags" values, so i place those values into attributes like this....
3
by: melanieab | last post by:
Hi, I can't seem to get the syntax correct. I have an xmlnodelist full of elements called "file". Each file has an attribute called "ID". If I just want to get, say, the ID of the second file...
2
by: Richard | last post by:
Hi, I am trying to use an XmlDocument object to manipulate the default database instance node of the enterprise template library dataConfiguration section from a custom installer step: <?xml...
2
by: phangmo | last post by:
Hi, When I run my program at home, there's no problem. But when I run it in office, I've got this error: ----------------------- Unhandled Exception: System.Net.WebException: The underlying...
1
by: Dica | last post by:
hi all first off, i'm not trying to cross post, but couldn't find this newsgroup earlier (got here from a recommendation on microsoft.public.vb, where i originally posted this question). ...
4
by: CodeRazor | last post by:
I am reading an xml file from a URL. I was originally doing this using the XmlDocument class. But this was very slow. The XmlTextReader is meant to be much quicker for forward only retrieval of...
2
by: David Thielen | last post by:
Hi; I have a node where it is "<w:t> </w:t>" and what I get from XmlTextReader is Element, SignificantWhitespace, EndElement instead of Element, Text, EndElement. Question 1 is why? The text...
0
by: fredrik | last post by:
Hi! I have a problem with reading a xmlfile from a url. I am confused by the long loading time of the first node. When the first node has been loaded, the rest of the nodes is parsed very fast. ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.