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

XMLnodelist and XPATH Problem

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
----------------------------------------------------------

Thanks
Nov 12 '05 #1
1 5771
Your XML has namespaces. See
http://samples.gotdotnet.com/quickst...NameSpace.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.

"Robert" <rl*****@att.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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
----------------------------------------------------------

Thanks

Nov 12 '05 #2

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

Similar topics

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...
11
by: Marina | last post by:
Hi, Given a node, how can one find out its index in the collection of nodes it belongs to? Thanks
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>
3
by: Maurice Cosgrave | last post by:
Hi, I was wondering if there was a way to move values from an array into an XmlNodeList? I have the values loaded into a string array from a previous point in the application; now I need to...
4
by: SkyHook | last post by:
1. Under the topic "Select Nodes Using XPath Navigation" it says: "All XmlNodeList objects are synchronized with the underlying document, therefore if you ... modify the value of a node, that node...
1
by: bigeddie | last post by:
Hi, I'm trying to get an instance off a XmlNodeList without using selectNodes(...) XmlNodeList test1 = new XmlNodeList(); (C#) but that doesn't work. What's my mistake?
1
by: Ramakrishna Pillai | last post by:
Hi all I have an XMLNodeList object which has the collection of xml nodes based on the search criteria with the help of XPath expression Now, how do I create a datatable with that so as to...
6
by: Raul | last post by:
Hi, I have the following code, which picks up 43 different nodes from my XML document XmlNodeList amortNodes = amortDoc.SelectNodes("// TValueAmortizationSchedule/AmortizationLine"); each...
9
by: DotNetNewbie | last post by:
Thanks all for the previous help btw. What is going on here? It works yet it doesn't want to work in a loop. XmlNodeList nodeList = root.SelectNodes(String.Format("/cars/ mfg",...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...

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.