|
-
Oct 16th, 2006, 01:22 AM
#1
Thread Starter
Fanatic Member
help with XML
hello guys! i have a code snippet below that basically retrieve some information from sharepoint portal list service which returns something in XML fragment in the following form that contains information about the list items and that can be assigned to a System.Xml.XmlNode object. But im having hard time in extracting the item one-by-one in each row like the LinkTitle, EventDate, etc. can anybody please help on this..Thanks in advance!!
Code;
Code:
List_Service.Lists listService = new List_Service.Lists();
//listService.Credentials= System.Net.CredentialCache.DefaultCredentials;
listService.Credentials = new NetworkCredential("absalvamante", "lovekoh++", "transco");
listService.PreAuthenticate = true;
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
ndQueryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" +
"<DateInUtc>TRUE</DateInUtc>";
ndViewFields.InnerXml = "<FieldRef Name='Title' /><FieldRef Name='EventDate'/>";
try
{
XmlNode ndListItems = listService.GetListItems("Events", null, ndQuery, null, null, ndQueryOptions);
MessageBox.Show(ndListItems.OuterXml);
}
catch (System.Web.Services.Protocols.SoapException ex)
{
MessageBox.Show("Message:\n" + ex.Message + "\nDetail:\n" + ex.Detail.InnerText + "\nStackTrace:\n" + ex.StackTrace);
}
Return Value:
Code:
<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="7">
<z:row ows_fRecurrence="0" ows_LinkTitle="(SP066) Negros - Panay Stage 2 - Opening of Bids" ows_EventDate="2006-10-20T05:30:00Z" ows_EndDate="2006-10-20T09:00:00Z" ows_Location="Dela Paz" ows_ID="8" ows_owshiddenversion="3" />
<z:row ows_fRecurrence="0" ows_LinkTitle="(SP073) Northern Panay - Opening of Bids" ows_EventDate="2006-10-20T05:30:00Z" ows_EndDate="2006-10-20T09:00:00Z" ows_Location="Dela Paz" ows_ID="19" ows_owshiddenversion="2" />
<z:row ows_fRecurrence="0" ows_LinkTitle="(SP072) Steel Pole-Sucat Araneta - Opening of Bids" ows_EventDate="2006-10-16T05:30:00Z" ows_EndDate="2006-10-16T09:00:00Z" ows_Location="Rodriguez" ows_ID="23" ows_owshiddenversion="3" />
<z:row ows_fRecurrence="0" ows_LinkTitle="(B06-08) Microwave SDH - Opening of Bids" ows_EventDate="2006-10-18T05:30:00Z" ows_EndDate="2006-10-18T09:00:00Z" ows_Location="Rodriguez" ows_ID="25" ows_owshiddenversion="3" />
<z:row ows_fRecurrence="0" ows_LinkTitle="(B06-07) Microwave Luzon-Visayas - Opening of Bids" ows_EventDate="2006-10-18T05:30:00Z" ows_EndDate="2006-10-18T09:00:00Z" ows_Location="Dela Paz" ows_ID="26" ows_owshiddenversion="1" />
<z:row ows_fRecurrence="0" ows_LinkTitle="(SP082) Makban Remaining Works - Bid Opening" ows_EventDate="2006-10-20T05:30:00Z" ows_Location="Rodriguez" ows_ID="32" ows_owshiddenversion="2" />
<z:row ows_fRecurrence="0" ows_LinkTitle="(B06-019) Steel Poles CY 2007 - Bid Opening" ows_EventDate="2006-10-25T02:00:00Z" ows_ID="34" ows_owshiddenversion="1" />
</rs:data>
</listitems>
Last edited by daimous; Oct 16th, 2006 at 01:28 AM.
-
Oct 16th, 2006, 01:25 PM
#2
Re: help with XML
Instead of MessageBox.Show...
EchoItems(ndListItems);
Code:
private void EchoItems(XmlNode xmlFragment)
{
XmlNamespaceManager nsManager = new XmlNamespaceManager(xmlFragment.OwnerDocument.NameTable);
nsManager.AddNamespace("s", "uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882");
nsManager.AddNamespace("dt", "uuid:C2F41010-65B3-11d1-A29F-00AA00C14882");
nsManager.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
nsManager.AddNamespace("z", "#RowsetSchema");
nsManager.AddNamespace("", "http://schemas.microsoft.com/sharepoint/soap/");
XmlNodeList rowNodes = xmlFragment.SelectNodes("rs:data/z:row", nsManager);
foreach (XmlNode rowNode in rowNodes)
{
Console.WriteLine(rowNode.Attributes.GetNamedItem("ows_LinkTitle").InnerText);
}
}
-
Oct 16th, 2006, 06:25 PM
#3
Thread Starter
Fanatic Member
Re: help with XML
Thanks i'll try that..but how can I get the uuid? like the
Code:
BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882
and
Code:
C2F41010-65B3-11d1-A29F-00AA00C14882
and what does necessarily mean? Thanks in advance!
-
Oct 18th, 2006, 08:20 AM
#4
Re: help with XML
SelectSingleNode()
SelectNodes()
This applies to the XMLDocument object as well. You only need to specify some XPath. Once you get many nodes, you loop through it.
-
Oct 19th, 2006, 06:43 PM
#5
Thread Starter
Fanatic Member
Re: help with XML
Thanks i got it! but i have another question currently i have XMl query below how will I modify it in such a way that it will return all rows where Alarm Column is equals to todays date.
Code:
ndQueryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" +
"<DateInUtc>FALSE</DateInUtc>";
ndQuery.InnerXml = "<Where><And><IsNotNull><fieldRef Name='Alarm'/></IsNotNull><IsNotNull><fieldRef Name='Alarm_x0020_For'/></IsNotNull></And></Where>";
can you guys help me with this or just give me a good link that might be of help for me to solve this problem. Thanks in advance!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|