2016-07-17 5 views
-1

ご覧のとおり、XMLノードの 'description'にはエスケープされたHTMLが含まれており、最初のimgのsrc属性を抽出する必要があります。 XPathでこれを行う方法はありますか?XPathを使用してXMLノード内の(エスケープされた)HTML属性を抽出できますか?

<item> 
    <description>&lt;img class=&quot;imagefield imagefield-field_teaser_astory&quot; width=&quot;481&quot; height=&quot;455&quot; alt=&quot;&quot; src=&quot;http://www.rightwingwatch.org/sites/default/files/images/a_story_rww/roundup_A_.jpg?1383082488&quot; /&gt; Is Trump Going To Run The Country The Way He&amp;rsquo;s Running This Convention?</description> 
</item> 
+0

」要素の内容を別の文書として解析する必要があります。 XPath(DOMXPath SimpleXML、他に何か)を実行するためにあなたは何を使用しますか? – har07

答えて

-1

あなたは、基本的な部分文字列関数を使用することができます。

substring-before(substring-after(/item/description/text(), 'src="'), '"') 

これは、ドキュメント順で最初の/item/descriptionテキストノードにsrc=""の間のすべてのテキストを検索します。

関連する問題