473,480 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

xpath for children

Hi all,
Following is a part of an Xml document I am having problems with. I have
a XmlNode variable in my C# application that referes to the mytable node of
the following Xml. Now I need to get all children of mytable node from the
ns0 namespace(myfield1 and myfield2 in this case) using the XmlNode object.
I need a help with Xpath query to achieve this.

Do you think the following statement would work?
mytablenode.SelectNodes("descendant::ns0:*",myname spacemanager);

<ns0:mydataset>
<ns0:mytable>
<w:p>
<ns0:myfield1>value</ns0:myfield1>
</w:p>
<w:p>
<ns0:myfield2>value</ns0:myfield2>
</w:p>
</ns0:mytable>
</ns0:mydataset>
Thanks in advance.
Nov 12 '05 #1
1 1810


helpful sql wrote:

Following is a part of an Xml document I am having problems with. I have
a XmlNode variable in my C# application that referes to the mytable node of
the following Xml. Now I need to get all children of mytable node from the
ns0 namespace(myfield1 and myfield2 in this case) using the XmlNode object.
I need a help with Xpath query to achieve this.

Do you think the following statement would work?
mytablenode.SelectNodes("descendant::ns0:*",myname spacemanager);
The expression is fine as long as the prefix ns0 is bound to the right
URI (e.g. you do
mynamespacemanager.Add("ns0", "namespaceURI")
before).
The shortcut notation for the XPath is
".//ns0:*"

<ns0:mydataset>
<ns0:mytable>
<w:p>
<ns0:myfield1>value</ns0:myfield1>
</w:p>
<w:p>
<ns0:myfield2>value</ns0:myfield2>
</w:p>
</ns0:mytable>
</ns0:mydataset>


Also note that your subject and your explanation says you are looking
for children of the mytable element but the XPath correctly looks for
descendant nodes (as that is what myfield1/myfield2 elements are.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2

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

Similar topics

2
2091
by: Jeff | last post by:
I'd like to write an XPath expression that gets a node with 2 particular children. I thought this would work: /AAA/BBB/CCC/following-silbing::DDD/parent::node() on xml like this: AAA BBB
7
1793
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange";...
3
2343
by: ArmsTom | last post by:
I've been playing around with xml for a couple days, so I have no idea what I'm doing yet :). Be gentle. Ok, here's what I have... ================================ Do while...
1
476
by: Simang | last post by:
Hi everyone, I'm an xpath newbie and needed help from all of you. I need to get all elements that do not have any children. Is there such an expression? I would need to use this for the...
4
1480
by: cgaden | last post by:
Hi everyone, I have a problem that I've been trying to figure out for a while but I just can't seem to get it right. I have the following XML fragment: <Page ID="x1" Schema="Folder"> -<Page...
2
1379
by: Candle | last post by:
I am new to XML Programming and I am hoping someone can help me out with this. Assuming I have the following XML: <root> <E C="P_E1" O="E1" Y='True'> <A C="P_E1A1" V="7" Y='True'/> <A...
1
1769
by: woodworthjames | last post by:
Hello, not sure i am using xpath correctly. have the following trivial xml. <?:xml version="1.0" standalone="yes" ?> <top attr="1"> content1 content2 <inner id="first" day="friday"> content3...
3
3063
by: Arndt Jonasson | last post by:
Let's say we have a schema (maybe expressed in XML Schema, but not necessarily so), that allows this instance document: <top> <txt>This is text</txt> <books> <book>Tarzan</book> <book>Harry...
0
7049
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,...
0
6912
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7052
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6744
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...
0
6981
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...
0
5348
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,...
0
4488
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...
0
3000
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...
0
188
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...

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.