Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TXMLDocument with Multiple Namespaces

892 views
Skip to first unread message

Chris Krohn

unread,
Apr 21, 2008, 3:56:52 PM4/21/08
to
I am trying to interface a small CodeGear Delphi 2007 app with a Microsoft Office
Sharepoint Server (MOSS). I am using the lists web service to return the XML of a
particular document on one of our subsites. When I try to parse this document with a
TXMLDcoument object, everything works great until I try and get the attributes or child
nodes. The XML looks like this:

<listitems xmlns="http://schemas.microsoft.com/sharepoint/soap/"
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">
<rs:data ItemCount="1">
<z:row ows_BL_x0020_AWB_x0020_Number="7342128"

ows_DocLink="http://iserver/subsite/Documents%20for%20Review%2FTSCW%2DCL0214/7342128_BillofLading_6212457_2008102193356.pdf,
http://iserver/subsite/Documents%20for%20Review%2FTSCW%2DCL0214/7342128_BillofLading_6212457_2008102193356.pdf"
ows_MetaInfo="794;#"
ows__ModerationStatus="0"
ows__Level="1"
ows_ID="794"
ows_owshiddenversion="3"
ows_UniqueId="794;#{2FC479E5-9DA0-4ED5-A29F-27B826AAE6F9}"
ows_FSObjType="794;#0"
ows_Created="2008-04-12T00:33:55Z"
ows_FileRef="794;#docportal/Lists/Documentation Repository/794_.000"/>
</rs:data>
</listitems>

You will notice that the data node is in the rs namespace and the row node is in the z
namespace. When I try to get a node as such:

XMLDoc.XML.Text := XML;
XMLDoc.Active := True;

Node := XMLDoc.DocumentElement.ChildNodes['data'];

ItemCount := RootNode.attributes['ItemCount'].nodeValue;

It fails with an error saying that node 'data' not found. I have also tried using
ChildNodes['rs:data'] with the same result.

I assume that there must be some way to set which namespace you want to use prior to
accessing the attributes but I am unsure as to how to do this. Does anyone have any
ideas?

Thanks
Chris
---
Chris Krohn
IT Manager
Cayman Islands Port Authority
ckrohn at caymanport dot com

Michael Justin

unread,
Apr 22, 2008, 1:40:49 AM4/22/08
to
> You will notice that the data node is in the rs namespace and the row node is in the z
> namespace.

Try GetAttributeNS:

ItemCount := StrToInt(RootNode.GetAttributNS('ItemCount',
'urn:schemas-microsoft-com:rowset'));

Hope this helps(tm)
--
Michael Justin
SCJP, SCJA
betasoft - Software for Delphi™ and for the Java™ platform
http://www.mikejustin.com - http://www.betabeans.de

Chris Krohn

unread,
Apr 22, 2008, 11:19:39 AM4/22/08
to
Thanks for the reply, but unfortunately, that didn't work. I tried that and I just get a
null value back. The funny thing is that I found that if I do:

RootNode.ChildNodes[0].AttributeNodes[0].NodeValue

it works. But I can't figure any way to access it other than by index postion.

Chris


On Tue, 22 Apr 2008 07:40:49 +0200, Michael Justin <michael...@nospam.gmx.net> wrote:

>> You will notice that the data node is in the rs namespace and the row node is in the z
>> namespace.
>
>Try GetAttributeNS:
>
>ItemCount := StrToInt(RootNode.GetAttributNS('ItemCount',
>'urn:schemas-microsoft-com:rowset'));
>
>Hope this helps(tm)

---

0 new messages