XpathNavigator.SelectChildren problem

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

    XpathNavigator.SelectChildren problem

    hi

    i have xml in this structue

    <?xml version="1.0" encoding="utf-8" ?>
    <obrazac sifra="N-08-V">
    <!--
    Stanje: u obradi
    Primjedbe: nema
    -->
    <odjeljak>
    <naslov>OBAVIJE ST O OBJAVI NA PROFILU NARUÈITELJA (KUPCA)</naslov>
    </odjeljak>
    <odjeljak sifra="P.1">
    <izmjena id="1">Objava se odnosi na objavljivanje</izmjena>
    <izmjena id="1-1">Prethodne (informacijske) obavijesti</izmjena>
    <izmjena id="1-2">Prethodne (indikativne) obavijesti - koja ne
    slu¾i kao poziv na nadmetanje</izmjena>
    </odjeljak>
    ....
    </obrazac>


    when i use XpathNavigator. SelectChildren( "@"//odjeljak[@sifra='P.1']",
    "") i get 0 nodes. what i need to put as second parameter
    (namespaceURI)? i dont have any namespace defined.
  • Martin Honnen

    #2
    Re: XpathNavigator. SelectChildren problem

    Gigs_ wrote:
    hi
    >
    i have xml in this structue
    >
    <?xml version="1.0" encoding="utf-8" ?>
    <obrazac sifra="N-08-V">
    <!--
    Stanje: u obradi
    Primjedbe: nema
    -->
    <odjeljak>
    <naslov>OBAVIJE ST O OBJAVI NA PROFILU NARUÈITELJA (KUPCA)</naslov>
    </odjeljak>
    <odjeljak sifra="P.1">
    <izmjena id="1">Objava se odnosi na objavljivanje</izmjena>
    <izmjena id="1-1">Prethodne (informacijske) obavijesti</izmjena>
    <izmjena id="1-2">Prethodne (indikativne) obavijesti - koja ne
    slu¾i kao poziv na nadmetanje</izmjena>
    </odjeljak>
    ....
    </obrazac>
    >
    >
    when i use XpathNavigator. SelectChildren( "@"//odjeljak[@sifra='P.1']",
    "") i get 0 nodes. what i need to put as second parameter
    (namespaceURI)? i dont have any namespace defined.
    If you want to pass in an XPath expression (e.g.
    //odjeljak[@sifra='P.1']) then use the Select method, not the
    SelectChildren method:

    XPathDocument doc = new XPathDocument(@ "..\..\XMLFile1 .xml");
    XPathNavigator nav = doc.CreateNavig ator();
    XPathNodeIterat or it = nav.Select(@"//odjeljak[@sifra='P.1']");
    Console.WriteLi ne(it.Count);

    That yields 1 for your posted XML sample.

    The SelectChildren method takes an element name (e.g. odjeljak) but not
    an XPath expression.


    --

    Martin Honnen --- MVP XML

    Comment

    • Gigs_

      #3
      Re: XpathNavigator. SelectChildren problem

      On May 31, 2:44 pm, Martin Honnen <mahotr...@yaho o.dewrote:
      Gigs_ wrote:
      hi
      >
      i have xml in this structue
      >
      <?xml version="1.0" encoding="utf-8" ?>
      <obrazac sifra="N-08-V">
      <!--
      Stanje: u obradi
      Primjedbe: nema
      -->
      <odjeljak>
      <naslov>OBAVIJE ST O OBJAVI NA PROFILU NARUÈITELJA (KUPCA)</naslov>
      </odjeljak>
      <odjeljak sifra="P.1">
      <izmjena id="1">Objava se odnosi na objavljivanje</izmjena>
      <izmjena id="1-1">Prethodne (informacijske) obavijesti</izmjena>
      <izmjena id="1-2">Prethodne (indikativne) obavijesti - koja ne
      slu¾i kao poziv na nadmetanje</izmjena>
      </odjeljak>
      ....
      </obrazac>
      >
      when i use XpathNavigator. SelectChildren( "@"//odjeljak[@sifra='P.1']",
      "") i get 0 nodes. what i need to put as second parameter
      (namespaceURI)? i dont have any namespace defined.
      >
      If you want to pass in an XPath expression (e.g.
      //odjeljak[@sifra='P.1']) then use the Select method, not the
      SelectChildren method:
      >
      XPathDocument doc = new XPathDocument(@ "..\..\XMLFile1 .xml");
      XPathNavigator nav = doc.CreateNavig ator();
      XPathNodeIterat or it = nav.Select(@"//odjeljak[@sifra='P.1']");
      Console.WriteLi ne(it.Count);
      >
      That yields 1 for your posted XML sample.
      >
      The SelectChildren method takes an element name (e.g. odjeljak) but not
      an XPath expression.
      >
      --
      >
      Martin Honnen --- MVP XML
      http://JavaScript.FAQTs.com/
      ok, but i just want to get list of specific odjeljak children and
      after some processing i want to go recursive to that children children
      if thez have it. for that i need XpathNavigator. SelectChildren,
      because i cannot know what children will be in specific node. how can
      i get specific odjeljka children

      Comment

      • Gigs_

        #4
        Re: XpathNavigator. SelectChildren problem

        On May 31, 2:44 pm, Martin Honnen <mahotr...@yaho o.dewrote:
        Gigs_ wrote:
        hi
        >
        i have xml in this structue
        >
        <?xml version="1.0" encoding="utf-8" ?>
        <obrazac sifra="N-08-V">
        <!--
        Stanje: u obradi
        Primjedbe: nema
        -->
        <odjeljak>
        <naslov>OBAVIJE ST O OBJAVI NA PROFILU NARUÈITELJA (KUPCA)</naslov>
        </odjeljak>
        <odjeljak sifra="P.1">
        <izmjena id="1">Objava se odnosi na objavljivanje</izmjena>
        <izmjena id="1-1">Prethodne (informacijske) obavijesti</izmjena>
        <izmjena id="1-2">Prethodne (indikativne) obavijesti - koja ne
        slu¾i kao poziv na nadmetanje</izmjena>
        </odjeljak>
        ....
        </obrazac>
        >
        when i use XpathNavigator. SelectChildren( "@"//odjeljak[@sifra='P.1']",
        "") i get 0 nodes. what i need to put as second parameter
        (namespaceURI)? i dont have any namespace defined.
        >
        If you want to pass in an XPath expression (e.g.
        //odjeljak[@sifra='P.1']) then use the Select method, not the
        SelectChildren method:
        >
        XPathDocument doc = new XPathDocument(@ "..\..\XMLFile1 .xml");
        XPathNavigator nav = doc.CreateNavig ator();
        XPathNodeIterat or it = nav.Select(@"//odjeljak[@sifra='P.1']");
        Console.WriteLi ne(it.Count);
        >
        That yields 1 for your posted XML sample.
        >
        The SelectChildren method takes an element name (e.g. odjeljak) but not
        an XPath expression.
        >
        --
        >
        Martin Honnen --- MVP XML
        http://JavaScript.FAQTs.com/
        thanks, but i need to get list of childrens and than do some
        processing on them and if they have children i will go deeper with
        recursion and again do some stuff if thez have children. but i dont
        know what children they have, so i need to use SelectChildren. how can
        i get children from specific odjeljak?

        Comment

        • gigs

          #5
          Re: XpathNavigator. SelectChildren problem

          Gigs_ wrote:
          On May 31, 2:44 pm, Martin Honnen <mahotr...@yaho o.dewrote:
          >Gigs_ wrote:
          >>hi
          >>i have xml in this structue
          >><?xml version="1.0" encoding="utf-8" ?>
          >><obrazac sifra="N-08-V">
          >> <!--
          >> Stanje: u obradi
          >> Primjedbe: nema
          >> -->
          >> <odjeljak>
          >> <naslov>OBAVIJE ST O OBJAVI NA PROFILU NARUÈITELJA (KUPCA)</naslov>
          >> </odjeljak>
          >> <odjeljak sifra="P.1">
          >> <izmjena id="1">Objava se odnosi na objavljivanje</izmjena>
          >> <izmjena id="1-1">Prethodne (informacijske) obavijesti</izmjena>
          >> <izmjena id="1-2">Prethodne (indikativne) obavijesti - koja ne
          >>slu¾i kao poziv na nadmetanje</izmjena>
          >> </odjeljak>
          >>....
          >></obrazac>
          >>when i use XpathNavigator. SelectChildren( "@"//odjeljak[@sifra='P.1']",
          >>"") i get 0 nodes. what i need to put as second parameter
          >>(namespaceURI )? i dont have any namespace defined.
          >If you want to pass in an XPath expression (e.g.
          >//odjeljak[@sifra='P.1']) then use the Select method, not the
          >SelectChildr en method:
          >>
          > XPathDocument doc = new XPathDocument(@ "..\..\XMLFile1 .xml");
          > XPathNavigator nav = doc.CreateNavig ator();
          > XPathNodeIterat or it = nav.Select(@"//odjeljak[@sifra='P.1']");
          > Console.WriteLi ne(it.Count);
          >>
          >That yields 1 for your posted XML sample.
          >>
          >The SelectChildren method takes an element name (e.g. odjeljak) but not
          >an XPath expression.
          >>
          >--
          >>
          > Martin Honnen --- MVP XML
          > http://JavaScript.FAQTs.com/
          >
          thanks, but i need to get list of childrens and than do some
          processing on them and if they have children i will go deeper with
          recursion and again do some stuff if thez have children. but i dont
          know what children they have, so i need to use SelectChildren. how can
          i get children from specific odjeljak?
          sorry for two post, mz mistake. just forget second

          Comment

          • Martin Honnen

            #6
            Re: XpathNavigator. SelectChildren problem

            Gigs_ wrote:
            ok, but i just want to get list of specific odjeljak children and
            after some processing i want to go recursive to that children children
            if thez have it. for that i need XpathNavigator. SelectChildren,
            because i cannot know what children will be in specific node. how can
            i get specific odjeljka children
            SelectChildren takes the element name thus if you know you want the
            child elements named 'odjeljka' then use that name with SelectChildren:
            nav.SelectChild ren("odjeljka", "")

            Or you use Select and pass in an XPath expression selecting specific
            children:
            nav.Select("odj eljka[@sifra='P.1']")


            --

            Martin Honnen --- MVP XML

            Comment

            Working...