473,320 Members | 1,993 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.

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 2619
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: 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...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.