たとえば、「ベルリンの歴史」を検索するとき、あなたは次のようなURLを要求しています
そして、あなたはこのようなXMLの結果を取り戻しています:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfResult
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://lookup.dbpedia.org/">
<Result>
<Label>Museum für Naturkunde</Label>
<URI>http://dbpedia.org/resource/Museum_für_Naturkunde</URI>
<Description></Description>
<Classes></Classes>
<Categories></Categories>
<Templates></Templates>
<Redirects></Redirects>
<Refcount>155</Refcount>
</Result>
<Result>
<Label>History of Berlin</Label>
<URI>http://dbpedia.org/resource/History_of_Berlin</URI>
<Description>
Berlin is the capital city of Germany. Berlin is a young city by European standards, founded in the 12th century.
</Description>
<Classes></Classes>
<Categories>
<Category>
<Label>History of Berlin</Label>
<URI>http://dbpedia.org/resource/Category:History_of_Berlin</URI>
</Category>
<Category>
<Label>History of Germany by location</Label>
<URI>http://dbpedia.org/resource/Category:History_of_Germany_by_location</URI>
</Category>
</Categories>
<Templates></Templates>
<Redirects></Redirects>
<Refcount>14</Refcount>
</Result>
</ArrayOfResult>
あなたは正しいです URI
カテゴリを持つ要素uris、例えば
<URI>http://dbpedia.org/resource/Category:History_of_Berlin</URI>
しかし、あなたが注意すべきは、ドキュメントの根源から、あるということです
ArrayOfResult/Result/Categories/Category/URI
一方、あなたが望む要素はそうです
ArrayOfResult/Result/URI
要素。 XMLを少し異なる方法で処理する必要があります。取得しないでください 全て からのコンテンツ 全て URI
要素ですが、 URI
の子供である要素 Result
要素。私はサックスの解析にそれほど精通しているわけではありませんが、重要なポイントは、あなたが入力したら Result
, 、あなたはをつかむだけです URI
別の子要素に入っていない場合 Result
.