У меня есть основной список XML, который ссылается на другие объекты XML, из которых я должен извлечь. Вот пример двух каналов:
<news state="Trial">
<newsListItem href="http://api.newsfeed.com/x/news/800614671/">
<id>800614671</id>
<publishDate>2011-10-10T14:17:08</publishDate>
</newsListItem>
<newsListItem....> // Many more news items
</news>
URL-адрес newsListItem указывает на дополнительный XML-документ, который выглядит следующим образом:
<newsItem encoding="UTF-8">
<id>800614671</id>
<state>Trial</state>
<publishDate>2011-10-10T14:17:08</publishDate>
<createdDate>2011-10-10T13:18:02</createdDate>
<lastModifiedDate>2011-10-10T14:18:38</lastModifiedDate>
<headline>Woman stabbed to death in south London</headline>
<extract>Officers have confirmed a woman has been stabbed to death in a Bexleyheath street this morning.</extract>
<categories href="http://api.newsfeed.com/x/news/800614671/categories/"/>
<text format="html"><p>By Guy Kilty</p>
<p>A woman has been stabbed to death and another has been injured in an attack in south London, police have confirmed.</p>
<p>Officers were called to a busy street near the Asda supermarket in the Broadway area of Bexleyheath at 08:30 BST this morning (October 10th) following reports that a woman had been stabbed.</p>
<p>The first victim was found with a stab wound and died at the scene, while the second had been stabbed in the hand and was taken to hospital.</p>
<p>A Metropolitan Police spokesman said: "Officers and the London Ambulance Service arrived on the scene and found a woman suffering stab wounds, who was pronounced dead at 8.41am.</p>
<p>"A second female suffered a knife injury to her hand. One woman has been arrested in connection with the incident."</p>
<p>Police had no immediate information about the age of any of the people involved or any reason for the attack.</p>
</text>
</newsItem>
Можно ли использовать XPath на основном фиде для получения данных от hrefs? Первоначально я смотрел на что-то вроде /news/newsListItem/@href/???/newsItem/headline
, но я не уверен, что это правильный путь. Это возможно даже с XPath?
Любой совет будет принят с благодарностью. Я впервые работаю с XPath.