2016-03-25 20 views
1

Kann jemand mir helfen, eine XPath Abfrage bitte zu formulieren? Ich habe diese XML-Datei über Post enthält Informationen von Facebook heruntergeladenBrauchen Sie Hilfe für eine XPath-Abfrage

... 
<Post> 
    <CreationDate>Sun Mar 20 08:20:00 CET 2016</CreationDate> 
    <Id>179618821150_10154060429226151</Id> 
    <Newspaper>Repubblica</Newspaper> 
    <Snippet>Da Roma alle Marche. Il cammino sacro apre ai ciclisti</Snippet> 
    <Text>Il ciclo-pellegrinaggio arriva anche in Italia</Text> 
    <Hashtags/> 
    <Likes>25</Likes> 
    <Shares>167</Shares> 
    <URL>http://larep.it/1Rtgs36</URL> 
    <Picture/> 
    <Sentiment>0</Sentiment> 
    <IsIndexed>True</IsIndexed> 
    <IsTokenized>False</IsTokenized> 
</Post> 
<Post> 
    <CreationDate>Wed Mar 16 18:10:00 CET 2016</CreationDate> 
    <Id>179618821150_10154051153841151</Id> 
    <Newspaper>Repubblica</Newspaper> 
    <Snippet>Il Dalai Lama scrive a Pannella: "Prego per te e la tua  famiglia"</Snippet> 
    <Text>La commovente lettera: "Come sai, ti considero un amico personale e un inamovibile amico del popolo tibetano di lunga data. Prego per te"</Text> 
    <Hashtags/> 
    <Likes>25</Likes> 
    <Shares>5</Shares> 
    <URL>http://larep.it/1nOztp9</URL> 
    <Picture/> 
    <Sentiment>0</Sentiment> 
    <IsIndexed>True</IsIndexed> 
    <IsTokenized>False</IsTokenized> 
</Post> 
... 

und ich brauche alle Elemente erhalten den Namen „Post“, die ein Element „ErstellDatum“ enthalten, die mit etwas Text X. starten Wie kann ich es tun Bitte? Ich bin derzeit mit dieser Abfrage aber es wählt nur ErstellDatum Elemente ...

/Posts/Post/CreationDate[starts-with(.,'" + someText + "')] 

Dank !!! :)

Antwort

2

Ihr XPath ist fast korrekt, außer dass es CreationDate anstelle von Post zurückgibt. Versuchen Sie, diese Art und Weise:

/Posts/Post[starts-with(CreationDate,'" + someText + "')] 
+1

vielen Dank! –

+1

Bitte bedanken Sie sich für die Antwort und/oder [diese Antwort akzeptieren] (http://meta.stackoverflow.com/q/5234/234215), wenn Ihnen geholfen wurde. – kjhughes

0

Versuchen:

/Posts/Post[CreationDate[starts-with(.,'" + someText + "')]]