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

Still having problems with NameSpaceManager

Hi,

I'm trying to extract data from objects that contain xml that fits a
third party schema with it's own root namespace. I've added a
namespace manager that seemed to work most of the time but I never
fully understood why. I've now hit another problem. It might be code
blindness but I can't see why it doesn't work.

I am trying to select a node using XPath from an XmlElement

XmlElement xEntityNode ;

/* xEntityNode's OuterXml is this
<facilityList xmlns="qvEntityTypes">
<facility>
<internalId>6</internalId>
<description>OrderOnLine</description>
<displayOrder>1</displayOrder>
</facility>
<facility>
<internalId>7</internalId>
<description>ConfirmHeldOrders</description>
<displayOrder>1</displayOrder>
</facility>
<facility>
<internalId>28</internalId>
<description>ViewProductStock</description>
<displayOrder>1</displayOrder>
</facility>
<facility>
<internalId>29</internalId>
<description>SeeOtherUsersOrders</description>
<displayOrder>1</displayOrder>
</facility>
<facility>
<internalId>30</internalId>
<description>Buy</description>
<displayOrder>1</displayOrder>
</facility>
</facilityList>
*/

// Here's my code
nsmgr = new XmlNamespaceManager( new System.Xml.NameTable() );
nsmgr.AddNamespace("qv", "qvEntityTypes") ;
XmlNode propertyNode = xEntityNode.SelectSingleNode(
"//qv:facilityList/qv:facility[description = \"Buy\"]" , nsmgr);

// END

SelectSingleNode returns null. I think the namespace applies to the
nested facility level hence the qv:facility.

Can anyone suggest a better way of dealing with the namespace?
Nov 12 '05 #1
2 2508
"Chris" <fr*******@surf.to> wrote in message news:57*************************@posting.google.co m...
It might be code blindness but I can't see why it doesn't work.
Definitely code blindness. ;-)

: : XmlNode propertyNode = xEntityNode.SelectSingleNode(
"//qv:facilityList/qv:facility[description = \"Buy\"]" , nsmgr);


The XPathExpression that successfully returns a node is,

//qv:facilityList/qv:facility[qv:description = 'Buy']

The prefix that you correctly used on each of the location
steps is also required on the child element, description, in
the expression's predicate.
Derek Harmon
Nov 12 '05 #2
Oh yeah. Should have tried that. Thanks :-)

"Derek Harmon" <lo*******@msn.com> wrote in message news:<#k*************@TK2MSFTNGP11.phx.gbl>...
"Chris" <fr*******@surf.to> wrote in message news:57*************************@posting.google.co m...
It might be code blindness but I can't see why it doesn't work.


Definitely code blindness. ;-)

: :
XmlNode propertyNode = xEntityNode.SelectSingleNode(
"//qv:facilityList/qv:facility[description = \"Buy\"]" , nsmgr);


The XPathExpression that successfully returns a node is,

//qv:facilityList/qv:facility[qv:description = 'Buy']

The prefix that you correctly used on each of the location
steps is also required on the child element, description, in
the expression's predicate.
Derek Harmon

Nov 12 '05 #3

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

Similar topics

4
by: Vishy | last post by:
Hi I'm trying to read xml file with namespacemanager; it seems that it adds up a namespace if there is none; How can avoid this? so <ID>00589</ID> becomes <Id...
687
by: cody | last post by:
no this is no trollposting and please don't get it wrong but iam very curious why people still use C instead of other languages especially C++. i heard people say C++ is slower than C but i can't...
8
by: Michael C | last post by:
Hi all, I'm still having problems with VS.NET 2003 running on my XP machine. I finally decided I might as well uninstall completely and reinstall from scratch. But lo and behold it won't let...
4
by: Charles | last post by:
I am still having problems with sessions crossing over from other sessions. What I mean by this is that Mary may get just some or all of Renae’s information. I think that what is going on with...
0
by: Wayne Wengert | last post by:
I am still having problems trying to run demos I download. I downloaded a ASP.NET Roadshow demo. It appears to include several "solutions". One sample is in a sub-directory named TipsTricks which...
8
by: Brad Simon | last post by:
I have written a shopping cart using ASP .NET (VB). It has been running quite successfully on a site for about a year or so. I use the SessionID as the key to hold information on the shopping...
14
by: Alan Silver | last post by:
Hello, I have spent ages trawling through Google, looking for information about global functions in ASP.NET and I'm still not clear about the best way to go about this (or not). I am writing...
0
by: Martin | last post by:
Hi, I am using xmldocument.selectsinglenode to query an xml document. This works perfectly when the document to be queried has no namespace, however as some as i put a namespace in then null is...
1
by: Bruce Sandeman | last post by:
Hi, Is anyone able to help me? I have the following code and when I try to create an XPathNavigator object it keeps returning null. any cunning ideas? private void loadXMLDoc(String xml) {...
3
by: rudeman76 | last post by:
Hi, I have a form that has no menu bar (so people cannot go playing) and when the admin presses the admin button they have to enter in a password. After they enter in the password the menubar...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.