Groups | Blog | Home
all groups > dotnet xml > august 2004 >

dotnet xml : XMLnodelist and XPATH Problem


Dare Obasanjo [MSFT]
8/27/2004 1:52:40 PM
Your XML has namespaces. See
http://samples.gotdotnet.com/quickstart/howto/doc/Xml/XmlNameSpace.aspx
specifically

"The document also has the default namespace of
http://schemas.microsoft.com/sharepoint/soap/ which we will map to the "ns"
namespace. The reason for needing a prefix for the default namespace in our
XPath query is due to the fact that in XPath, there is no concept of a
default namespace. Instead elements and attributes that have a namespace
require a prefix for matching while unprefixed names in queries can only be
used for elements or that do not have a namespace (i.e. are in the null
namespace). "

--
This posting is provided "AS IS" with no warranties, and confers no rights.

[quoted text, click to view]

Robert
8/27/2004 3:10:34 PM
I am having a problem selecting nodes using the XMLnodelist Selectnodes
using XPATH when I use XML SPY is successfully queries but when is use
VB.net it comes up with nothing.

Here is my code

Dim nodess As XmlNode
nodess = myNode.SelectSingleNode("//Web[@Url=
'http://localhost']")
If nodess Is Nothing Then
SQLrw.Delete()
End If
nodess = Nothing

The myNode Properites
------------------------------------------------------------------------------------------------
{System.Xml.XmlElement}
[System.Xml.XmlElement]: {System.Xml.XmlElement}
Attributes: {System.Xml.XmlAttributeCollection}
BaseURI: ""
ChildNodes: {System.Xml.XmlChildNodes}
FirstChild: {System.Xml.XmlElement}
HasChildNodes: True
InnerText: ""
InnerXml: "<Web Title=" WSS Beta Site" Url="http://localhost"
xmlns="http://schemas.microsoft.com/sharepoint/soap/" /><Web Title="AD
Migration Project" Url="http://localhost/ADMIG"
xmlns="http://schemas.microsoft.com/sharepoint/soap/" /><Web
Title="Architecture &amp; Planning" Url="http://localhost/cm/Archi
tecture" xmlns="http://schemas.microsoft.com/sharepoint/soap/" />>
IsReadOnly: False
Item: <cannot view indexed property>
LastChild: {System.Xml.XmlElement}
LocalName: "Webs"
Name: "Webs"
NamespaceURI: "http://schemas.microsoft.com/sharepoint/soap/"
NextSibling: Nothing
NodeType: Element
OuterXml: "<Webs
xmlns="http://schemas.microsoft.com/sharepoint/soap/"><Web Title=" WSS
Beta Site" Url="http://localhost" /><Web Title="AD Migration Project"
Url="http://localhost/ADMIG" /><Web Title="Architecture &amp; Planning"
Url="http://localhost/cm/Architecture" />
OwnerDocument: {System.Xml.XmlDocument}
ParentNode: Nothing
Prefix: ""
PreviousSibling: Nothing
Value: Nothing
----------------------------------------------------------

AddThis Social Bookmark Button