Filtre de la réponse d'un webservice
Bonjour,
Alors voila je récupére la liste des documents d'un "document lib" de sharepoint via le webservice "lists.asmx"
Le probléme est que je n'arrive pas à filtrer correctement avec le querry, et je me retrouve systématiquement avec des charactére *poluant* exemple:
#mavariable
et la réponse compléte pour un item :
Citation:
<z:row ows_FileLeafRef="1;#test.doc" ows_Last_x0020_Modified="1;#2008-03-19 10:18:38" ows_ID="1" ows_owshiddenversion="1" ows_FSObjType="1;#0" ows_Modified="2008-03-19 10:18:37" ows_FileRef="1;#path/test.doc" ows_Editor="1;#domain\admin" ows_DocIcon="doc" xmlns:z="#RowsetSchema" />
Au niveau de mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
System.Xml.XmlElement query = xmlDoc.CreateElement("Query");
System.Xml.XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
System.Xml.XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");
query.InnerXml = "";// +
query.InnerText = "<Where><Lt><FieldRef Name=\"FileLeafRef\" /><Value Type=\"Counter\">3</Value></Lt></Where>";
viewFields.InnerXml = "<FieldRef Name=\"FileLeafRef\" />";
queryOptions.InnerText = "<IncludeMandatoryColumns>FALSE </IncludeMandatoryColumns> <DateInUtc>TRUE</DateInUtc>";
// items
XmlNode nodeListItems = listService.GetListItems(listName, null, query, viewFields, null, queryOptions);
XmlNode allLists = listService.GetListCollection();
// load into an XML document so we can use XPath to query content
XmlDocument allListsDoc = new XmlDocument();
allListsDoc.LoadXml(allLists.OuterXml);
XmlNamespaceManager ns = new XmlNamespaceManager(allListsDoc.NameTable);
ns.AddNamespace("d", allLists.NamespaceURI);
XmlDocument xmlResultsDoc = new XmlDocument();
xmlResultsDoc.LoadXml(nodeListItems.OuterXml);
ns = new XmlNamespaceManager(xmlResultsDoc.NameTable);
ns.AddNamespace("z", "#RowsetSchema");
XmlNodeList rows = nodeListItems.SelectNodes("//z:row", ns);
if (rows.Count == 0)
{//no doc
}
foreach (XmlNode row in rows)
{
textBox3.Text += row.Attributes["ows_FileLeafRef"].Value + "\t";
textBox3.Text += row.Attributes["ows_Modified"].Value + "\t";
textBox3.Text += row.Attributes["ows_Editor"].Value + "\t\t";
textBox3.Text += row.Attributes["ows_FileRef"].Value;
textBox3.Text += "\r\n";
} |
Je pense que le problème vient du Querry ou du ViewField voir du QuerryOptions..
Bon au pire je ferais un SubString mais c'est quand même dommage 8O