Need Help for Xpath

  • 15 years ago

    Hello, I am a newbie in Xpath. I have an XML document containing routing table shown below. I have been strugling for days on how to write xpath query to extract <agenttype> and <pref> nodes which destination address <startbrigade> is 7 AND <start_node> is 252  :'( .


    this is how i select out <pref> <agent type> and <start_node> in <brigade 7>


    System.Xml.XmlNodeList RouteList = xmldoc.SelectNodes("//startbrigade[. = '7']/ancestor::node()/pref | //startbrigade[. = '7']/ancestor::node()/agenttype|//startbrigade[. = '7']/parent::node()/start_node")


    but i want to further select out < pref >and <agenttype> which has <startnode> 252 only...


    Could anyone help please ?




           <entry>
               <nextnode>
                   <briagade>7</briagade>
                   <node>252</node>
               </next
    node>
               <agenttype>13</agenttype>
               <pref>3</pref>
               <destinationaddress>
                   <start
    brigade>7</startbrigade>
                   <start
    node>252</startnode>
                   <end
    brigade>7</endbrigade>
                   <end
    node>252</endnode>
               </destination
    address>
           </entry>



           <entry>
               <nextnode>
                   <briagade>7</briagade>
                   <node>253</node>
               </next
    node>
               <agenttype>12</agenttype>
               <pref>1</pref>
               <destinationaddress>
                   <start
    brigade>7</startbrigade>
                   <start
    node>253</startnode>
                   <end
    brigade>7</endbrigade>
                   <end
    node>253</endnode>
               </destination
    address>
           </entry>


           <entry>
               <nextnode>
                   <briagade>7</briagade>
                   <node>253</node>
               </next
    node>
               <agenttype>12</agenttype>
               <pref>1</pref>
               <destinationaddress>
                   <start
    brigade>7</startbrigade>
                   <start
    node>253</startnode>
                   <end
    brigade>7</endbrigade>
                   <end
    node>253</endnode>
               </destination
    address>
           </entry>


           <entry>
               <nextnode>
                   <briagade>7</briagade>
                   <node>253</node>
               </next
    node>
               <agenttype>12</agenttype>
               <pref>1</pref>
               <destinationaddress>
                   <start
    brigade>8</startbrigade>
                   <start
    node>253</startnode>
                   <end
    brigade>8</endbrigade>
                   <end
    node>253</endnode>
               </destination
    address>
           </entry>




    Any help are greatly appreciated..
    Thank you in advance


    kyu

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debuggers don't remove bugs. They only show them in slow motion.”