473,587 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
May 31 '08 #1
5 7153
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/
May 31 '08 #2
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
May 31 '08 #3
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?
May 31 '08 #4
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
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.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
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
4080
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 other words, I initially create an XPathNavigator for my entire xml document. To get an XPathNavigator object who's root is a given node in the original xml document, there is a unique xpath that will return that node. The unique xpath could have,...
2
2888
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 object with no problem, but what I cannot seem to do is get at the actual XML string itself. For accountability, tracking, auditing, and logging, I need to save the XML as an XML file in an archive folder, but there doesn't seem to be any way of...
4
7440
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 between <mytag> and </mytag>, the text I'm looking for, but also all the text portion of every sub tag (but not the tags themselves). Is there a method in the MVP XML library or some other work around I can user to get only the text of the parent...
1
3742
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> <destination>
11
6438
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); XPathNavigator nav = docNav.CreateNavigator(); XmlDocument doc = new XmlDocument(); doc.LoadXml("<DocumentData></DocumentData>"); XmlElement elem = doc.CreateElement(currentNodeName);
1
6348
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 the attributes. If I have some XML: <ApplicationConfiguration Test="Blahblah" AnotherAttr="asdfasd">
2
9032
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 name="account"> <attribute name="accountid" /> </entity> </entityConfiguration>
1
2811
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 Excel). Using XPathNavigator I managed to read some of the data, but in order to do this I had to manually remove the attributes from the Parent Nodes. Going forward this isnt an option as we may be reading and running hundreds of files a day and so I...
5
230
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
7927
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
7981
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8222
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6632
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5396
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3846
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2367
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1457
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1194
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.