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

xpath of SelectNodes() does not work when tag contains xmlns

hi

i have a problem querying a simple atom-feed by xpath using the
XmlDocument. i'm googleing for hours now and can't get a solution:

--- Code ---
XmlDocument doc = new XmlDocument();
doc.Load(XmlReader.Create(_feed.AbsoluteUri));
XmlNodeList list = doc.SelectNodes("feed");
// list.Count is always 0

--- XML-Document ---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>test</title>
</feed>

now as far as i take out the xmlns="http://www.w3.org/2005/Atom" the
xpath expression just works fine and SelectNodes() returns some
elements. however the atom feed contains this xmlns by default and i
have to deal with it.

what is my fault?
thanks for every hint
jazper manto
Aug 27 '08 #1
1 2414

XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("xsd", "http://tempuri.org/DSRenewal.xsd");

foreach (XmlNode xmlNode in rootNode.SelectNodes("xsd:RenewalInv", nsmgr))
"Jazper" <ja**********@nospam.newsgroup.comwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
hi

i have a problem querying a simple atom-feed by xpath using the
XmlDocument. i'm googleing for hours now and can't get a solution:

--- Code ---
XmlDocument doc = new XmlDocument();
doc.Load(XmlReader.Create(_feed.AbsoluteUri));
XmlNodeList list = doc.SelectNodes("feed");
// list.Count is always 0

--- XML-Document ---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>test</title>
</feed>

now as far as i take out the xmlns="http://www.w3.org/2005/Atom" the
xpath expression just works fine and SelectNodes() returns some
elements. however the atom feed contains this xmlns by default and i
have to deal with it.

what is my fault?
thanks for every hint
jazper manto

Aug 27 '08 #2

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

Similar topics

4
by: Andreas Baier | last post by:
Hi, I want to select all "result" nodes from the following xml-document: ---- <results xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <list...
4
by: Gismo | last post by:
I have got file raport.rld which is an XML file generated by MS Reporting Services. The problem is: in this file are tags from two different namespaces ...
2
by: ree32 | last post by:
When I import an xml document in Visual studio and Genereate as schema from it, and create a dataset from it, it adds this line into to the root element of my xml file -...
2
by: Echo 8 | last post by:
Is there a simple way of compare dates? I am trying to create a list of perishable stock in an inventory that is near or past its expiration date. I've tried telling it to compare a node's value...
3
by: news.microsoft.com | last post by:
I am using client script to handle some XML stuff with MS XMLDOM But I ran into a problem in selecting the elements using selectNodes method The XML looks like: <root> ...........................
6
by: AMDRIT | last post by:
Hello Everyone, I am having an issue with xml and namespaces, at least I think it is namespaces. When I use namespaces, I cannot use SelectSingleNode / SelectNodes as they always return...
1
by: jesper_lofgren | last post by:
Hello, i need to help here. I have a xmlnode as you can se below (full xml is in the bottom). I wonder how i can get the values inside the CSammanstallningLista . <CSammanstallning...
14
by: Mikhail Teterin | last post by:
Hello! What's would be the syntax for a query, which would allow me to get only the elements with non-empty text-nodes? For example, from: <a><b></b></a> <c/> <d><e>meow</e></d>
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.