472,127 Members | 2,101 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 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 8217
"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by MacDk | last post: by
8 posts views Thread by e-mid | last post: by
1 post views Thread by Riko Eksteen | last post: by
2 posts views Thread by Linda Boumarafi | last post: by
2 posts views Thread by Joe | last post: by
2 posts views Thread by DeveloperX | last post: by
3 posts views Thread by John Smith | last post: by
reply views Thread by leo001 | last post: by

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.