473,324 Members | 2,248 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,324 software developers and data experts.

How get specific element in XMLDocument?

This XML works fine:

XmlNodeList _XmlNodeList = _XmlDocument.GetElementsByTagName("Path");
However, I want only the particular "Path" element that is nested here:

DeploymentData/AvailableTemplates/FormatTemplate/BackgroundUrl/Path
This doesn't work:

XmlNodeList _XmlNodeList =
_XmlDocument.GetElementsByTagName("DeploymentData/AvailableTemplates/FormatTemplate/BackgroundUrl/Path");
Any idea what does?

Thanks.

Jul 20 '08 #1
2 7289
XmlNode _XmlNode =
_XmlDocument.SelectSingleNode("/DeploymentData/AvailableTemplates/FormatTemplate/BackgroundUrl/Path");

Notice the leading slash in the XPath expression. You can read more about
XPath expressions here: http://www.codeproject.com/KB/cpp/myXPath.aspx.

Best Regards,
Stanimir Stoyanov | www.stoyanoff.info

"Ronald S. Cook" <rc***@westinis.comwrote in message
news:EC**********************************@microsof t.com...
This XML works fine:

XmlNodeList _XmlNodeList = _XmlDocument.GetElementsByTagName("Path");
However, I want only the particular "Path" element that is nested here:

DeploymentData/AvailableTemplates/FormatTemplate/BackgroundUrl/Path
This doesn't work:

XmlNodeList _XmlNodeList =
_XmlDocument.GetElementsByTagName("DeploymentData/AvailableTemplates/FormatTemplate/BackgroundUrl/Path");
Any idea what does?

Thanks.
Jul 20 '08 #2
Thanks Stanimir.

"Stanimir Stoyanov" <st******@live.comwrote in message
news:7D**********************************@microsof t.com...
XmlNode _XmlNode =
_XmlDocument.SelectSingleNode("/DeploymentData/AvailableTemplates/FormatTemplate/BackgroundUrl/Path");

Notice the leading slash in the XPath expression. You can read more about
XPath expressions here: http://www.codeproject.com/KB/cpp/myXPath.aspx.

Best Regards,
Stanimir Stoyanov | www.stoyanoff.info

"Ronald S. Cook" <rc***@westinis.comwrote in message
news:EC**********************************@microsof t.com...
>This XML works fine:

XmlNodeList _XmlNodeList = _XmlDocument.GetElementsByTagName("Path");
However, I want only the particular "Path" element that is nested here:

DeploymentData/AvailableTemplates/FormatTemplate/BackgroundUrl/Path
This doesn't work:

XmlNodeList _XmlNodeList =
_XmlDocument.GetElementsByTagName("DeploymentDa ta/AvailableTemplates/FormatTemplate/BackgroundUrl/Path");
Any idea what does?

Thanks.
Jul 20 '08 #3

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

Similar topics

1
by: Andy Fish | last post by:
Hi, I'm using XML DOM in Java and I have a function like this Element makeSomeXml(Document doc) {..} This returns an Element owned by (but not appended to) the specified document. Now,...
1
by: pjeung | last post by:
Say that I have an element <elementA> that has several layers of subelements. In System.Xml.XmlDocument and related classes, how do I rename <elementA> to <elementB> leaving the subelements intact?
4
by: mike | last post by:
Hello. Let's say I have the following XML document: <ROOT><Element1>Some Text</Element1></ROOT> I want to add a new element after Element1. I tried the following but, naturally, it doesn't...
0
by: BC3Tech | last post by:
I'm creating a system that uses XML to store an audit trail of the steps that it has been through in the system. The way the schema is defined, there is a "Tag" for every application that...
4
by: David Dvali | last post by:
Hello. I have such XML file: <root> <elem1> <optional> Some data <optional> </elem1> </root>
1
by: Ryan Liu | last post by:
Hi, I know I need create a DataRow from a DataTable for the schema reason. Why must I create a XmlElement in a XmlDocument? I already have a string, I was trying to use...
4
by: FabrizioSW | last post by:
Hi all i've to create a xml doc like this <?xml version="1.0" encoding="UTF-8"?> <Main xmlns:x="http://www.w3.org/1999/XML/xinclude"> <x:include href="one.xml"/> <x:include href="two.xml"/>...
6
by: DWrek | last post by:
Here is my problem. I have an XML document that is returned to me by a third party service. The XML document contains results for a search but only lists a maximum of 10 results. If there are any...
4
by: BizTalk Benjamin | last post by:
Hi, I have an XmlDocument loaded from a memory stream. I set the document element prefix in this way XmlElement e = xDoc.DocumentElement; e.Prefix = "abc" When i simply write the document...
4
by: Alan T | last post by:
I used XmlDocument to load from a file. Then how do I append an element to the end? <files> <file> <name>graphic.txt</name> <location>c:\temp</location> </file>
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
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...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
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.