XPath problem

  • Thread starter Thread starter Marina
  • Start date Start date
M

Marina

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.
 
Marina said:
<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)
 
Back
Top