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

XPath problem

Hi I have the following top most node:

<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.microsoft.com/MicrosoftNotificationServices/ApplicationDef
initionFileSchema">

....
</Application>

It has a bunch of other nodes inside. I am trying to use .NET and XPATH to
locate certain nodes. However, the xmlns attributes are getting in the way.
If I remove them, my SelectSingleNode calls work perfectly.

I have tried:

Dim xmlNamespace As New XmlNamespaceManager(adf.NameTable)
xmlNamespace.AddNamespace("",
"http://www.microsoft.com/MicrosoftNotificationServices/ApplicationDefinitio
nFileSchema")
xmlNamespace.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema")
xmlNamespace.AddNamespace("xsi", http://www.w3.org/2001/XMLSchema-instance)

Even a call such as:

myDoc.SelectSingleNode("Application", xmlNamespace)

fail as long as those attributes are there.

And then passing in the xmlNamespace object to the SelectSingleNode method,
but that's not working.

What is the correct way of dealing with this issue?

Thanks.

Jul 21 '05 #1
2 2628
Marina wrote:
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.microsoft.com/MicrosoftNotificationServices/ApplicationDef
initionFileSchema">

It has a bunch of other nodes inside. I am trying to use .NET and XPATH to
locate certain nodes. However, the xmlns attributes are getting in the way.
If I remove them, my SelectSingleNode calls work perfectly.

I have tried:

Dim xmlNamespace As New XmlNamespaceManager(adf.NameTable)
xmlNamespace.AddNamespace("",
"http://www.microsoft.com/MicrosoftNotificationServices/ApplicationDefinitio
nFileSchema")
xmlNamespace.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema")
xmlNamespace.AddNamespace("xsi", http://www.w3.org/2001/XMLSchema-instance)

Even a call such as:

myDoc.SelectSingleNode("Application", xmlNamespace)

fail as long as those attributes are there.

And then passing in the xmlNamespace object to the SelectSingleNode method,
but that's not working.

What is the correct way of dealing with this issue?


xmlNamespace.AddNamespace("foo",
"http://www.microsoft.com/MicrosoftNotificationServices/ApplicationDefinitionFileSchema")
myDoc.SelectSingleNode("foo:Application", xmlNamespace)

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Jul 21 '05 #2
Thanks, that did the trick.

"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:Ob**************@TK2MSFTNGP09.phx.gbl...
Marina wrote:
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.microsoft.com/MicrosoftNotificationServices/ApplicationDef initionFileSchema">

It has a bunch of other nodes inside. I am trying to use .NET and XPATH to locate certain nodes. However, the xmlns attributes are getting in the way. If I remove them, my SelectSingleNode calls work perfectly.

I have tried:

Dim xmlNamespace As New XmlNamespaceManager(adf.NameTable)
xmlNamespace.AddNamespace("",
"http://www.microsoft.com/MicrosoftNotificationServices/ApplicationDefinitio nFileSchema")
xmlNamespace.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema")
xmlNamespace.AddNamespace("xsi", http://www.w3.org/2001/XMLSchema-instance)
Even a call such as:

myDoc.SelectSingleNode("Application", xmlNamespace)

fail as long as those attributes are there.

And then passing in the xmlNamespace object to the SelectSingleNode method, but that's not working.

What is the correct way of dealing with this issue?
xmlNamespace.AddNamespace("foo",

"http://www.microsoft.com/MicrosoftNotificationServices/ApplicationDefinitio
nFileSchema") myDoc.SelectSingleNode("foo:Application", xmlNamespace)

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Jul 21 '05 #3

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

Similar topics

0
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
1
by: Murtaza Tinwala | last post by:
Hi mates, I have the following problem in XSLT. I have following variables: ref-file = <path of XML document> eg "xmlDoc.xml" repeatpath = <a repeat path expressed in Xpath like /root/person >...
4
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a...
3
by: Kathy Burke | last post by:
Hi again, I'm using the following xpath (works in visualizer) with a SelectSingleNode("xpath") statement. //Station/(WI])]/@order Problem is I get an error "expression passed to this method...
3
by: muscha | last post by:
Hi All, I have this weird problem. I have an xml document and tried to do an XPath query to it. If I use the SelectSingleNode method it throws an exception but it works with SelectNodes method....
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 -...
3
by: abcd_68 | last post by:
Hi there, I'm using, for the first time, the JDK1.5 Xpath API. I need to find elements in a Hibernate-generated .hbm.xml file. These files come with a <!DOCTYPE header mentioning a remote URL....
6
by: J.Marsch | last post by:
I must be completely losing my mind. I have some code that writes to config files. It works great with app.config files, but fails miserably with web.config files. For the life of me, I cannot...
5
by: jorgedelgadolopez | last post by:
Hi all, I am using the xpathnavigator evaluate function on .net (xpath 1 right?). Now I need to expand the code to do multiple contains, compare dates (such as 'before', 'between' and 'after'),...
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: 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
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,...
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
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...

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.