473,320 Members | 1,953 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,320 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 2511
"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...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.