473,664 Members | 3,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(XmlRea der.Create(_fee d.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 2442

XmlNamespaceMan ager nsmgr = new XmlNamespaceMan ager(xmlDoc.Nam eTable);
nsmgr.AddNamesp ace("xsd", "http://tempuri.org/DSRenewal.xsd") ;

foreach (XmlNode xmlNode in rootNode.Select Nodes("xsd:Rene walInv", nsmgr))
"Jazper" <ja**********@n ospam.newsgroup .comwrote in message
news:%2******** **********@TK2M SFTNGP05.phx.gb l...
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(XmlRea der.Create(_fee d.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
3947
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 id="{678737D9-2BF3-4FF7-A60E-5AA68595C8FB}"/> <versioning enabled="1"/> <settings url="http://racoon/TestDokumente/_layouts/1033/LstSetng.aspx?List={678737D9-
4
8970
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 xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini tion" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
2
2875
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 - "xmlns="http://tempuri.org/nameOfRoot.xsd" I have no idea what its pointing to & what is tempuri.org? So when this tag is in my xml tag my xpath query never works. But when I delete it work fine.
2
7745
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 with a DateTime string, but that doesn't work. I've assumed that it is easier to manipulate today's date instead of the date in my ExpireDate element. Thankyou in advanced for taking the time to read this and possibly helping me
3
1381
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> ........................ <Table> <PK>3</cls_PK>
6
3007
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 0/Nothing respectively. Anyone have any thoughts? Thanks in advance VB.Net 2005
1
2872
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 Id="Omrade" DefaultInclude="0"> <Rubrik>Område</Rubrik> <Text>Kallhäll. Fabriksvägen, Hus S, JÄRFÄLLA</Text> </CSammanstallning>
14
17003
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
8437
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8861
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8778
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4185
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.