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

GetListItems SelectNodes not working for me

I am getting no nodes from the following code:

'Put user code to initialize the page here
Dim listService As New com.domain.my.Lists
listService.Credentials =
System.Net.CredentialCache.DefaultCredentials
Dim xmlDoc = New System.Xml.XmlDocument

Dim ndQuery As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element,
"Query", "")
Dim ndViewFields As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element,
"ViewFields", "")
Dim ndQueryOptions As XmlNode =
xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "")

ndQueryOptions.InnerXml =
"<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" + _
"<DateInUtc>TRUE</DateInUtc>"
ndViewFields.InnerXml = "<FieldRef Name='Title'/><FieldRef
Name='URL'/><FieldRef Name='Category'/>"
ndQuery.InnerXml = ""

Try

Dim ndListItems As XmlNode = listService.GetListItems("Toolbar",
Nothing, ndQuery, ndViewFields, Nothing, ndQueryOptions)

Dim doc As XmlDocument = New XmlDocument
doc.LoadXml(Replace(ndListItems.InnerXml, ControlChars.Lf &
ControlChars.Lf, ""))
Dim nsmgr As XmlNamespaceManager = New
XmlNamespaceManager(doc.NameTable)
nsmgr.AddNamespace("z", "#RowsetSchema")
nsmgr.AddNamespace("rs", "urn:schemas-microsoft.com:rowset")
Dim node As XmlNode
Dim xl As XmlNodeList = doc.SelectNodes("/rs:data/z:row", nsmgr)
For Each node In xl
Debug.WriteLine(node.Attributes("ows_Title"))
Next
Debug.WriteLine(ndListItems.InnerXml)

Catch ex As System.Web.Services.Protocols.SoapException

Debug.WriteLine("Message:" & vbCrLf & ex.Message + vbCrLf +
"Detail:" + vbCrLf + ex.Detail.InnerText + ControlChars.Lf + "StackTrace:" +
ControlChars.Lf + ex.StackTrace)
End Try

The following is the Outer XML that I am receiving back, which clearly has
records.

<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"
xmlns="http://schemas.microsoft.com/sharepoint/soap/">

<rs:data ItemCount="3">
<z:row ows_Title="Yahoo" ows_URL="http://www.yahoo.com"
ows_Category="Sites" ows_ID="1" ows_owshiddenversion="1" />
<z:row ows_Title="Google" ows_URL="http://www.google.com"
ows_Category="Tools" ows_ID="2" ows_owshiddenversion="1" />
<z:row ows_Title="SharePoint Help"
ows_URL="/_vti_bin/help/1033/sps/html/SharePointHelp.htm" ows_Category="Help"
ows_ID="3" ows_owshiddenversion="3" />
</rs:data>
</listitems>

Am I missing something?

Thanks!

Nov 12 '05 #1
3 8313
"Steve" <St***@discussions.microsoft.com> wrote in message news:04**********************************@microsof t.com...
I am getting no nodes from the following code: : : nsmgr.AddNamespace("rs", "urn:schemas-microsoft.com:rowset") : : xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" : : Am I missing something?


It all seems to be in order, except that the xmlns declaration of rs in the
instance document is

urn:schemas-microsoft-com:rowset

whereas the xmlns declaration you've added to the XmlNamespaceManager
is

urn:schemas-microsoft.com:rowset

If you look closely, you'll observe a dot-com in this namespace URI
whereas the URN has dash-com. This revision should help,

nsmgr.AddNamespace("rs", "urn:schemas-microsoft-com:rowset")
Derek Harmon
Nov 12 '05 #2
Derek,

Thank you very much! Even after reading your email I didn't see it right
away, but that did it.

Steve

"Derek Harmon" <lo*******@msn.com> wrote in message
news:eS**************@TK2MSFTNGP14.phx.gbl...
"Steve" <St***@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
I am getting no nodes from the following code:

: :
nsmgr.AddNamespace("rs", "urn:schemas-microsoft.com:rowset")

: :
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"

: :
Am I missing something?


It all seems to be in order, except that the xmlns declaration of rs in
the
instance document is

urn:schemas-microsoft-com:rowset

whereas the xmlns declaration you've added to the XmlNamespaceManager
is

urn:schemas-microsoft.com:rowset

If you look closely, you'll observe a dot-com in this namespace URI
whereas the URN has dash-com. This revision should help,

nsmgr.AddNamespace("rs", "urn:schemas-microsoft-com:rowset")
Derek Harmon

Nov 12 '05 #3

I am having a similar problem getting blank nodes. I have attached m
code (C#)

+----------------------------------------------------------------
| Attachment filename: code.txt
|Download attachment: http://www.mcse.ms/attachment.php?postid=3566859
+----------------------------------------------------------------

-
ckfinle
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1285233.htm

Nov 12 '05 #4

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

Similar topics

1
by: MacDk | last post by:
Hi, Given this: http://rss.asdf.dk/theothermusic.rss how do you use selectnodes/Xpath to return all title-items (//title is not working). I think it a problem with namespace but i can't...
8
by: e-mid | last post by:
i want to get childs of specific xml node. normally i use xmlNodeList fooList = myNode.SelectNodes("foo"); but in compactframework , there is no selectNodes() method or selectSingleNode()...
1
by: Riko Eksteen | last post by:
Hi I am writing an application that listens to the NodeInserted event, and if the event is fired it does a selectnodes xpath query on the XmlDocument. Only problem is, when I call...
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...
2
by: Linda Boumarafi | last post by:
Hi, This is a newbie question to XMLNS. I just finished the article on "XML Namespaces and How They Affect XPath and XSLT" by Dare Obasanjo and I'm pretty sure I understand the problem. I just...
2
by: Joe | last post by:
Hello All: Does anyone know the differnce between the GetElementsByTagName method and the SelectNodes method? I know that they take different arguments. They also both return a NodeList. I'm...
2
by: DeveloperX | last post by:
SelectNodes under 1.1 is confusing me. Imagine an xml file that looks like this. It's just an example: <drive> <dir a="a"> <file>aA</file> <file>aB</file> <dir a="ab"> <file>abA</file> <dir...
3
by: John Smith | last post by:
I'm trying to make some Javascript X-browser. foo is a HTML DOM. I have foo.documentElement.selectNodes("xpath"); in the source. I see later down there is also a foo.transformNode. Yuck. ...
3
by: Alan Mailer | last post by:
Ok, I've looked for an answer for this, because I'm sure it's been asked a thousand times... but no luck... so here goes. Imagine I want to create a NodeList based on an XPath statement. The...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.