Help--XML file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carmine

    #1

    Help--XML file

    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="ISO88 59-1" ?>
    - <Pentheus>
    - <occupation>
    <king>Thebe from 1954 to 2000</king>
    <prince>Danimar k from 1940 to 1954</prince>
    <jester>durin g the reign of TEST</jester>
    <Test>from 123 to 1234</Test>
    </occupation>
    <Mother url="http://google.com">Aga ve</Mother>--HERE-------------HERE---
    <url>prova123 </url>
    <Father>Echio n</Father>
    prova
    - <food>
    <name>French Toast</name>
    <price>$4.50</price>
    <description>th ick slices made from our homemade sourdough
    bread</description>
    <calories>600 </calories>
    </food>
    - <dog>
    <name>Attanasiu s</name>
    <race>crossbree d</race>
    <description>wo nderfull dog</description>
    <size>950</size>
    </dog>
    </Pentheus>
  • Dave Marteinson

    #2
    Re: Help--XML file

    Hi Carmine,

    "Carmine" <bladeone@katam ail.com> wrote in message
    news:bc9c4fbf.0 311061024.2eb18 677@posting.goo gle.com...[color=blue]
    > 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.[/color]

    Have a look at System.Xml.XmlD ocument.SelectS ingleNode()

    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


    Comment

    Working...