473,387 Members | 1,757 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,387 software developers and data experts.

XmlDocument.SelectNodes returning zero nodes

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

Nov 12 '05 #1
4 4641


George wrote:
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> 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.


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

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
Thanks for your advice!

- Andrew

Martin Honnen wrote:
George wrote:
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>

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.


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

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Nov 12 '05 #3
If I have the following line of code: -

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

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

Nov 12 '05 #4
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

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Seong-Tae Jeong | last post by:
for example, xml document is below, It has a default namespace "xmlns='qwer://test'". string xmlText = "<test xmlns='http://test'><clear/><clear/></test>"; I would like to select node list...
2
by: Dave | last post by:
Hi, Is there an easier way to pull a subset of nodes from one XmlDocument to another? I have the code below but would like to know if there is a more streamlined method. Thanks, Dave ...
8
by: pete | last post by:
Hi there, Can someone explain to me why I can't bind to an XmlDocument but I can bind to an XmlNodeList. It's my understanding that they both implement the IEnumerable interface which is...
2
by: Michael H | last post by:
Hello group, I have a some xml that looks like this below: <tuneRequests ct="3" xmlns:sql="urn:schemas-microsoft-com:xml-sql" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <tr...
1
by: Peter Nofelt | last post by:
Hey All, I'm running into this issue with parsing through an xml document by tag name. Below is an example xml document: File Name: things.xml <things> <people> <name>Peter</name>
16
by: PiotrKolodziej | last post by:
Hi I'am using SelectNodes method to find if node followed by string exists, and if so i going to select that node. Create doc i such a way: doc = new XmlDocument(); ...
3
by: 0to60 | last post by:
Please help! I'm using the following code to get an XML doc: string str = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=12345&city=addison"; System.Net.HttpWebRequest request =...
0
by: Karel Kral | last post by:
Hello, I have created simple COM service in .NET. COM is accessed from another not NET application by late binding call. And the problem: If I call NetComClass.Hello from another .NET code, all...
1
by: =?Utf-8?B?RGF2aWRHQg==?= | last post by:
OK, so I've created and loaded an XMLDocument object. But how do I go about using it? Specifically, how do I: 1) move to the first node (I assume I start on it when I load the XML?) 2) move to...
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: 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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.