xpath query problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajasekharsiva
    New Member
    • Jan 2008
    • 7

    xpath query problem

    hi all,
    i am new to .net i have problem
    i have an xml fille lik this:::

    <?xml version="1.0" encoding="utf-8"?>
    <personal_inf o>
    <personal_id ID="1">
    <name first_name="raj asekhar" middle_name="si va" last_name="alur u" nick_name="sekh ar" />
    <gender value="Male" />
    <group group_name="bes tfriends" parent_group="F riends" />
    </personal_id>
    <personal_id ID="2">
    <name first_name="kir an" middle_name="ku mar" last_name="kara nam" nick_name="kira n" />
    <gender value="Male" />
    <group group_name="xyz company" parent_group="C ollegues" />
    </personal_id>
    </personal_info>


    from this file how can select the only the parent_group which are not sub gruops. i.e first lebel parent groups.....

    i have used following query .....
    //group[@group_name != @parent_group]

    i am getting the following result
    bestfriends
    collegues
    friends

    but i need oonly,

    collegues
    friends

    please any one can guide me
    Last edited by kenobewan; Feb 4 '08, 11:22 AM. Reason: MERGED - MULTIPOSTING NOT ALLOWED - SEE POSTING GUIDELINES
  • rajasekharsiva
    New Member
    • Jan 2008
    • 7

    #2
    generalzing the xpathexpression using variables

    hi to all,

    i am new to this forum and also new to xml too...

    i have an xml query to select a list of values...

    XmlNodeList nl=doc.SelectNo des("//group[@group_name='Fr iends']/@group_name")

    it can select only the node having value as Friends

    i want to generalize the query by substituting a variable in place of 'Friends'

    how can i do .....
    pls guide me

    Comment

    • ajayvaram
      New Member
      • Dec 2007
      • 14

      #3
      Originally posted by rajasekharsiva
      hi to all,

      i am new to this forum and also new to xml too...

      i have an xml query to select a list of values...

      XmlNodeList nl=doc.SelectNo des("//group[@group_name='Fr iends']/@group_name")

      it can select only the node having value as Friends

      i want to generalize the query by substituting a variable in place of 'Friends'

      how can i do .....
      pls guide me

      Can u send full code,then it is to run and find exactly
      ..
      Ajay

      Comment

      • ajayvaram
        New Member
        • Dec 2007
        • 14

        #4
        Originally posted by rajasekharsiva
        hi all,
        i am new to .net i have problem
        i have an xml fille lik this:::

        <?xml version="1.0" encoding="utf-8"?>
        <personal_inf o>
        <personal_id ID="1">
        <name first_name="raj asekhar" middle_name="si va" last_name="alur u" nick_name="sekh ar" />
        <gender value="Male" />
        <group group_name="bes tfriends" parent_group="F riends" />
        </personal_id>
        <personal_id ID="2">
        <name first_name="kir an" middle_name="ku mar" last_name="kara nam" nick_name="kira n" />
        <gender value="Male" />
        <group group_name="xyz company" parent_group="C ollegues" />
        </personal_id>
        </personal_info>


        from this file how can select the only the parent_group which are not sub gruops. i.e first lebel parent groups.....

        i have used following query .....
        //group[@group_name != @parent_group]

        i am getting the following result
        bestfriends
        collegues
        friends

        but i need oonly,

        collegues
        friends

        please any one can guide me
        Hi,
        I've some db't is SelectNodes working for the abue xml query?
        bye using SelectSingleNod e,it giving result only one value..
        so u send full logic code then, i can try in my system ..

        Comment

        Working...