all groups > dotnet xml > may 2005 >
You're in the

dotnet xml

group:

XmlDocument.SelectNodes returning zero nodes



Re: XmlDocument.SelectNodes returning zero nodes Martin Honnen
5/30/2005 12:00:00 AM
dotnet xml:

[quoted text, click to view]

See the article
<http://www.faqts.com/knowledge_base/view.phtml/aid/34022/fid/616>

--

Martin Honnen --- MVP XML
XmlDocument.SelectNodes returning zero nodes George
5/30/2005 3:14:19 AM
XML Sample 1 : -

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 U (http://www.xmlspy.com) by PHS Group plc
(PHS Group plc) -->
<EntityConfiguration
xmlns="x-schema:C:/QuantivProjects/QuantivT/Scheme/QuantivBase/QTVConfiguration/EntityConfiguration.xdr"
xmlns:dt="urn:schemas-microsoft-com:datatypes">
<MajorVersion>1</MajorVersion>
<MinorVersion>0</MinorVersion>
<EntityDef>
<EntityClassId>601</EntityClassId>
<EntityClassRef>Customer</EntityClassRef>
etc.

XML Sample 2 : -

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 U (http://www.xmlspy.com) by PHS Group plc
(PHS Group plc) -->
<EntityConfiguration>
<MajorVersion>1</MajorVersion>
<MinorVersion>0</MinorVersion>
<EntityDef>
<EntityClassId>601</EntityClassId>
<EntityClassRef>Customer</EntityClassRef>
etc.

Sample Code : -
Dim doc As XmlDocument
Dim xpathExpr As String =
"EntityConfiguration/EntityDef/EntityClassRef"

doc = New XmlDocument
doc.Load(xmlFile)
For Each node As XmlNode In doc.SelectNodes(xpathExpr)

entityList.Add(node.InnerXml)
log(String.Format("{0} - {1} = {2}", node.NodeType, node.Name,
node.InnerXml))

Next


If I run the sample code with XML Sample 1 I get no nodes returned,
however if I run the code with XML Sample 2 I get the expected node
set.

Could someone explain to me why this is?

Many thanks,

- Andy
Re: XmlDocument.SelectNodes returning zero nodes George
6/8/2005 12:35:00 AM
Thanks for your advice!

- Andrew

[quoted text, click to view]
Re: XmlDocument.SelectNodes returning zero nodes George
6/8/2005 12:56:42 AM
If I have the following line of code: -

Dim xmlNodeListLinkedEntityList As XmlNodeList =
nodeToProcess.SelectNodes("descendant::LinkedEntityListAttribute")

How would I modify the line above to into account the prefix as
described in the 'How do you match elements in the default namespace
(e.g. xmlns="uri") in XPath 1.0 with .NET?' article?

Thanks in advance for your help!!

- Andrew
Re: XmlDocument.SelectNodes returning zero nodes George
6/8/2005 1:10:53 AM
Martin,

I have the following line in my XML file...

<EntityConfiguration xmlns="x-schema:C:/EntityConfiguration.xdr"
xmlns:dt="urn:schemas-microsoft-com:datatypes">

I am sure that is information is probably relevant:)

- Andrew
AddThis Social Bookmark Button