2016-03-25 24 views
1

Birisi bana bir xpath sorgusu oluşturmama yardımcı olabilir mi? Ben facebookBir xpath sorgusu için yardıma ihtiyacınız var

... 
<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> 
... 

indirilen yazı hakkında bilgi içeren bu xml dosyası var ve bazı metin X ile başlamak unsuru "creationDate" içeren "Post" adlı tüm unsurları almak gerekir Bunu yapabilen nasıl Lütfen? ...

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

sayesinde Şu anda bu sorguyu kullanıyorum ancak yalnızca CreationDate elemanlarını seçer !!!

cevap

2

XPath, Post yerine CreationDate döndürmesi dışında neredeyse doğru. Bu şekilde deneyin:

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

çok teşekkür ederim! –

+1

Size yardım ederse, teşekkür ederek ve/veya [bu cevabı kabul ederek] (http://meta.stackoverflow.com/q/5234/234215) teşekkür ederiz. – kjhughes

0

Dene:

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