473,322 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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>OBAVIJEST 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.
May 31 '08 #1
5 7112
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>OBAVIJEST 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.CreateNavigator();
XPathNodeIterator it = nav.Select(@"//odjeljak[@sifra='P.1']");
Console.WriteLine(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/
May 31 '08 #2
On May 31, 2:44 pm, Martin Honnen <mahotr...@yahoo.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>OBAVIJEST 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.CreateNavigator();
XPathNodeIterator it = nav.Select(@"//odjeljak[@sifra='P.1']");
Console.WriteLine(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
May 31 '08 #3
On May 31, 2:44 pm, Martin Honnen <mahotr...@yahoo.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>OBAVIJEST 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.CreateNavigator();
XPathNodeIterator it = nav.Select(@"//odjeljak[@sifra='P.1']");
Console.WriteLine(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?
May 31 '08 #4
Gigs_ wrote:
On May 31, 2:44 pm, Martin Honnen <mahotr...@yahoo.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>OBAVIJEST 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.CreateNavigator();
XPathNodeIterator it = nav.Select(@"//odjeljak[@sifra='P.1']");
Console.WriteLine(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
May 31 '08 #5
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.SelectChildren("odjeljka", "")

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

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 31 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: David Thielen | last post by:
Hi; Is there a way from an XPathNavigator object to get an xpath string that will, when used in a Select(xpath) on the underlying base/root XPathNavigator return the same XPathNavigator? In...
2
by: JSheble | last post by:
I'm integrating with a customer application, and in their assembly, when I call a method it returns data to us as an XPathNavigator object. I can parse the various elements I need out of this...
4
by: Jack Fox | last post by:
I'm navigating through a XPathDocument consisting of mostly mixed complex type elements (i.e. innertext plus more elements). When I use XPathNavigator.Value to retrieve the text I get everything...
1
by: gustavo_randich | last post by:
Hi, given the following simple XML fragment: <country> <code>ES</code> <description>SPAIN</description> <destination> <code>IBZ</code> <description>IBIZA</description> </destination>...
11
by: ericms | last post by:
Can anybody show me how to insert a CDATA section using XPathNavigator ? I have tried the follwing with no luck: XmlDocument docNav = new XmlDocument(); docNav.LoadXml(xmlString);...
1
by: Keith Patrick | last post by:
I'm converting over from using XmlNodes (specifically ConfigXmlNode, but the API uses XmlNode) to IXPathNavigable in some methods I have, but I'm finding in the process, that I can't seem to get...
2
by: Jiho Han | last post by:
I have an xml document as follows: <?xml version="1.0" encoding="utf-8" ?> <entityConfiguration xmlns="http://schemas.infinityinfo.com/entityconfiguration" version="1.0"> <entity...
1
by: WestyCHC | last post by:
Morning all from a newbie. I have recently written an automation program (my first ever program) for testing and now I am trying to read XML data and assign the values to variables (rather than...
5
by: Gigs_ | last post by:
hi i have xml in this structue <?xml version="1.0" encoding="utf-8" ?> <obrazac sifra="N-08-V"> <!-- Stanje: u obradi Primjedbe: nema -->
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpī 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.