私はxpathを使用してepgファイルからコンテンツを検索していますが、このソースでは自分のコードは機能しません。そして今、私は自分自身でこれを解決することができないという点まで来ました。 XMLはこのように見えます(ご覧のとおり、2つの名前空間、v3、v31)。xpathと名前空間を持つすべての兄弟ノードを取得する
<?xml version="1.0" encoding="UTF-8"?>
<v3:schedule timestamp="2017-05-12T16:11:06.595Z" xmlns:v3="http://common.tv.se/schedule/v3_1">
<v3:from>2017-05-12T22:00:00.000Z</v3:from>
<v3:to>2017-05-13T22:00:00.000Z</v3:to>
...
<v3:contentList>
<v31:content timestamp="2017-05-12T16:11:06.595Z" xmlns:v31="http://common.tv.se/content/v3_1">
<v31:contentId>content.1375706-006</v31:contentId>
<v31:seriesId>series.40542</v31:seriesId>
<v31:seasonNumber>3</v31:seasonNumber>
<v31:episodeNumber>6</v31:episodeNumber>
<v31:numberOfEpisodes>8</v31:numberOfEpisodes>
<v31:productionYear>2017</v31:productionYear>
...
<v3:eventList>
<v31:event timestamp="2017-05-12T16:11:06.595Z" xmlns:v31="http://common.tv.se/event/v3_1">
<v31:eventId>event.26072881</v31:eventId>
<v31:channelId>channel.24</v31:channelId>
<v31:rerun>true</v31:rerun>
<v31:live>false</v31:live>
<v31:hidden>false</v31:hidden>
<v31:description/>
<v31:timeList>
<v31:time type="public">
<v31:startTime>2017-05-12T22:55:00.000Z</v31:startTime>
<v31:endTime>2017-05-12T23:55:00.000Z</v31:endTime>
<v31:duration>01:00:00:00</v31:duration>
</v31:time>
</v31:timeList>
<v31:contentIdRef>content.1375706-006</v31:contentIdRef>
<v31:materialIdRef>material.1010161108005267221</v31:materialIdRef>
<v31:previousEventList/>
<v31:comingEventList/>
</v31:event>
...
<v3:materialList>
<v31:material timestamp="2017-05-12T16:11:06.595Z" xmlns:v31="http://common.tv.se/material/v3_1">
<v31:materialId>material.1010161108005267221</v31:materialId>
<v31:contentIdRef>content.1375706-006</v31:contentIdRef>
<v31:materialType>tx</v31:materialType>
<v31:videoFormat>576i</v31:videoFormat>
<v31:audioList>
<v31:format language="unknown">stereo</v31:format>
</v31:audioList>
<v31:aspectRatio>16:9</v31:aspectRatio>
<v31:materialReferenceList>
</v31:materialReferenceList>
</v31:material>
...
「contentIdRef」は、さまざまな要素(イベントとマテリアル)をまとめたものです。 そして、私はcontentIdRefに基づいてすべてのデータを探したいと思います。
私はこの(PHPで)使用しています
$parent = $this->xmldata->xpath('//v31:event/v31:contentIdRef[.="content.1375706-006"]/parent::*')
を、私はまた
$parent = $this->xmldata->xpath('//v31:event/v31:contentIdRef[.="content.1375706-006"]/parent::*/child::*');
を試してみました。しかし、ちょうど(しますprint_r付き)最初の選択肢は、V31を返します。イベント "タイムスタンプ"
2番目の選択肢は空白の11個の「simpleXMLobjects」を返すので、オブジェクトの量に基づいて、「スポットに当たった」と思うが、なぜそれらを見つけることができないのだろうか?はempですty ....
はい、私はコード全体で名前空間を登録しています(私はそれが簡単だったと思います)。
TLDR; 私は最初のブロック(V3:contentList)からのすべてのcontentIds取得1.したい、私は心からあなたがすることを願って
...各コンテンツIDのすべてのmaterialdataを取得 3、 2.各コンテンツIDのためのすべてのeventdataのを取得help:/
こんにちは、 はい、私はます$ this-> xmldata-> registerXpathNamespaceのように、右の$親の前にそれらを登録しました。 :/ – DreamHawk