Sto interrogando Sharepoint lato server e recuperando i risultati come Xml. Voglio ridimensionare l'Xml in qualcosa di più leggero prima di inviarlo a jQuery attraverso un WebMethod.Perché questa query XPath non restituisce alcun nodo?
Tuttavia, la mia query XPath non funziona. Ho pensato che il seguente codice avrebbe restituito tutti i nodi Document, ma non restituisce nulla. Ho usato XPath un po 'prima, pensavo che lo //Document
facesse il trucco.
C# query XPath
XmlDocument xmlResults = new XmlDocument();
xmlResults.LoadXml(xml); // XML is a string containing the XML source shown below
XmlNodeList results = xmlResults.SelectNodes("//Document");
XML interrogato
<ResponsePacket xmlns="urn:Microsoft.Search.Response">
<Response domain="QDomain">
<Range>
<StartAt>1</StartAt>
<Count>2</Count>
<TotalAvailable>2</TotalAvailable>
<Results>
<Document relevance="126" xmlns="urn:Microsoft.Search.Response.Document">
<Title>Example 1.doc</Title>
<Action>
<LinkUrl size="32256" fileExt="doc">http://hqiis99/Mercury/Mercury documents/Example 1.doc</LinkUrl>
</Action>
<Description />
<Date>2010-08-19T14:44:56+01:00</Date>
</Document>
<Document relevance="31" xmlns="urn:Microsoft.Search.Response.Document">
<Title>Mercury documents</Title>
<Action>
<LinkUrl size="0" fileExt="aspx">http://hqiis99/mercury/Mercury documents/Forms/AllItems.aspx</LinkUrl>
</Action>
<Description />
<Date>2010-08-19T14:49:39+01:00</Date>
</Document>
</Results>
</Range>
<Status>SUCCESS</Status>
</Response>
</ResponsePacket>
L'XPath restituirebbe l Nodi 'Document' nel file XML di origine. Sei sicuro che siano lì e in tal caso sei sicuro che la variabile 'results' è vuota? – Oded
La variabile stringa xml contiene l'XML mostrato sopra, ho aggiornato il mio codice sorgente con un commento per comunicare questo –