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

Problems with SelectSingleNode

I have the following XML ('Offer' only appears once in the XML):

<OfferSheetXML xmlns="http://localhost/GBWPipeline/OfferSheetSchema.xsd">
<Offer>
<OfferSheetId>31</OfferSheetId>
[...]
</Offer>
</OfferSheetXML>

If I want to use the SelectSingleNode method of the XmlDocument object to
get either OfferSheetXML or Offer as an XmlNode, what do I need to use for
the xpath parameter of SelectSingleNode? Nothing I've tried so far works
(OfferSheetXML, /OfferSheetXML, //OfferSheetXML, Offer, //Offer,
OfferSheetXML/Offer, /OfferSheetXML/Offer, etcc).

Thanks.

Colin
Nov 12 '05 #1
5 2267
see this article:

http://www32.brinkster.com/srisamp/n...s/article_17.h
tm

Sonu Kapoor
http://weblogs.asp.net/sonukapoor/
-----Original Message-----
I have the following XML ('Offer' only appears once in the XML):
<OfferSheetXML xmlns="http://localhost/GBWPipeline/OfferSheetSchema.xsd"> <Offer>
<OfferSheetId>31</OfferSheetId>
[...]
</Offer>
</OfferSheetXML>

If I want to use the SelectSingleNode method of the XmlDocument object toget either OfferSheetXML or Offer as an XmlNode, what do I need to use forthe xpath parameter of SelectSingleNode? Nothing I've tried so far works(OfferSheetXML, /OfferSheetXML, //OfferSheetXML, Offer, //Offer,OfferSheetXML/Offer, /OfferSheetXML/Offer, etcc).

Thanks.

Colin
.

Nov 12 '05 #2
Thanks for Sonu's quick response!

Hi Colin,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know how to get the single
node reference using SelectSingleNode method. If there is any
misunderstanding, please feel free to let me know.

Just as Sonu's link mentioned, we also need to specify the namespace for
the xpath. Please try to add the following code to your code. It works fine
on my computer.

XmlNamespaceManager nsmRequest = new XmlNamespaceManager(doc.NameTable);
nsmRequest.AddNamespace("ns1",
"http://localhost/GBWPipeline/OfferSheetSchema.xsd");
XmlNode n = doc.SelectSingleNode("//ns1:OfferSheetXML", nsmRequest);

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #3
Thanks for the code Colin!

Sonu
Blog: http://weblogs.asp.net/sonukapoor/
-----Original Message-----
Thanks for Sonu's quick response!

Hi Colin,

First of all, I would like to confirm my understanding of your issue. Fromyour description, I understand that you need to know how to get the singlenode reference using SelectSingleNode method. If there is anymisunderstanding, please feel free to let me know.

Just as Sonu's link mentioned, we also need to specify the namespace forthe xpath. Please try to add the following code to your code. It works fineon my computer.

XmlNamespaceManager nsmRequest = new XmlNamespaceManager(doc.NameTable); nsmRequest.AddNamespace("ns1",
"http://localhost/GBWPipeline/OfferSheetSchema.xsd");
XmlNode n = doc.SelectSingleNode ("//ns1:OfferSheetXML", nsmRequest);
HTH. If anything is unclear, please feel free to reply to the post.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers norights."

.

Nov 12 '05 #4
uups...I meant thanks Kevin.

Sonu
Blog: http://weblogs.asp.net/sonukapoor/
-----Original Message-----
Thanks for the code Colin!

Sonu
Blog: http://weblogs.asp.net/sonukapoor/
-----Original Message-----
Thanks for Sonu's quick response!

Hi Colin,

First of all, I would like to confirm my understanding
ofyour issue. From
your description, I understand that you need to know howto get the single
node reference using SelectSingleNode method. If there

isany
misunderstanding, please feel free to let me know.

Just as Sonu's link mentioned, we also need to specifythe namespace for
the xpath. Please try to add the following code to your

code. It works fine
on my computer.

XmlNamespaceManager nsmRequest = new

XmlNamespaceManager(doc.NameTable);
nsmRequest.AddNamespace("ns1",
"http://localhost/GBWPipeline/OfferSheetSchema.xsd");
XmlNode n = doc.SelectSingleNode

("//ns1:OfferSheetXML", nsmRequest);

HTH. If anything is unclear, please feel free to reply

tothe post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties,
andconfers no
rights."

.

.

Nov 12 '05 #5
Thanks to both of you for the responses. I was able to solve the problem by
adding a namespace manager as suggested. I would have responded earlier to
say that was the solution, but my computer died and I just got it back
today.

Colin

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:yY*************@cpmsftngxa10.phx.gbl...
Thanks for Sonu's quick response!

Hi Colin,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know how to get the single
node reference using SelectSingleNode method. If there is any
misunderstanding, please feel free to let me know.

Just as Sonu's link mentioned, we also need to specify the namespace for
the xpath. Please try to add the following code to your code. It works fine on my computer.

XmlNamespaceManager nsmRequest = new XmlNamespaceManager(doc.NameTable);
nsmRequest.AddNamespace("ns1",
"http://localhost/GBWPipeline/OfferSheetSchema.xsd");
XmlNode n = doc.SelectSingleNode("//ns1:OfferSheetXML", nsmRequest);

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #6

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

Similar topics

0
by: fremenusul | last post by:
I am trying to have XML data show results in a combobox (Which works) and when the combobox has a selection, change the text in a label field. I am following the video from...
4
by: fremenusul | last post by:
am trying to have XML data show results in a combobox (Which works) and when the combobox has a selection, change the text in a label field. I am following the video from...
0
by: fremenusul | last post by:
am trying to have XML data show results in a combobox (Which works) and when the combobox has a selection, change the text in a label field. I am following the video from...
3
by: John R. | last post by:
I have an application written in C# and i am using MS XML DOM! I have a document with the following structure (only the <DicEntry> - Elements are important): <NewDataSet...
7
by: Sashi | last post by:
Two questions: (1) I can pull the text of an XML element as a string just fine using code as such: strSomeString = myXmlDoc.SelectSingleNode("/Element1/Element2/Element3",...
5
by: Chua Wen Ching | last post by:
Hi, I read from this tutorial at codeproject Question A: http://www.codeproject.com/csharp/GsXPathTutorial.asp regarding xpath.. but i try to apply in my situation, and can't get it...
7
by: John Bowman | last post by:
Hi All, I'm fairly new to XML, so I presume I'm doing something obviously dense here, but here it goes. Below is an XML file that was extracted from a test Windows Installer .MSP (patch) file...
1
by: PaulF | last post by:
I am trying to do add a repeating XmlNode into and existing XML document and have had some problems. The base XML: <Property> <Premises> <Endorsement> <ShortWording/> <Wording/>
0
by: compumate99 | last post by:
I am trying to parse the xml document using selectsinglenode method. I am doing this using Visual Foxpro >>> loResultXml = CreateObject("Microsoft.XMLDOM") With loResultXml .Async = .F. ...
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: 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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.