473,385 Members | 2,210 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,385 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 2626
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: 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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.