473,385 Members | 1,356 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,385 software developers and data experts.

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 1804


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
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
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
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
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
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
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
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
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
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.