Help--XML file

  • Thread starter Thread starter Carmine
  • Start date Start date
C

Carmine

Hi NG
i have the following problem:
In this file xml i want to extract the attribuite url situated in the
node mather. in ather word i want to put the contet of url, in this
case "http://google.com", in a string variable.
Now what do you suggest? i know i have to use the package System.Xml
(in c#) but i don't find the method that allow me to extract this
information from this node!
thanks in advance
Carmine
<?xml version="1.0" encoding="ISO8859-1" ?>
- <Pentheus>
- <occupation>
<king>Thebe from 1954 to 2000</king>
<prince>Danimark from 1940 to 1954</prince>
<jester>during the reign of TEST</jester>
<Test>from 123 to 1234</Test>
</occupation>
<Mother url="http://google.com">Agave</Mother>--HERE-------------HERE---
<url>prova123</url>
<Father>Echion</Father>
prova
- <food>
<name>French Toast</name>
<price>$4.50</price>
<description>thick slices made from our homemade sourdough
bread</description>
<calories>600</calories>
</food>
- <dog>
<name>Attanasius</name>
<race>crossbreed</race>
<description>wonderfull dog</description>
<size>950</size>
</dog>
</Pentheus>
 
Hi Carmine,

Carmine said:
Hi NG
i have the following problem:
In this file xml i want to extract the attribuite url situated in the
node mather. in ather word i want to put the contet of url, in this
case "http://google.com", in a string variable.

Have a look at System.Xml.XmlDocument.SelectSingleNode()

One possible XPath expression for this might be /Pentheus/Mother/@url
but it can of course be more general.
See http://www.w3.org/TR/xpath#path-abbrev for some XPath samples.
If there's a match in the instance you'll get back a node of type
Xml.Attribute and its Value property is the string you want.

Regards,

-djm
 
Back
Top