I have a stupid problem with php simplexml xpath which I don't understand.
xml structure:
<tv>
<programme start="zeitbla" stop="zeitbla2" channel="19">
<title>erstertitelbla</title>
<desc>blablabeschreibung</desc>
<category lang="ja_JP">情報</category>
<category lang="en">information</category>
</programme>
<programme start="zeitbla" stop="zeitbla2" channel="19">
<title>zweitertitelbla</title>
<desc>blablabeschreibung</desc>
<category lang="ja_JP">ニュース・報道</category>
<category lang="en">news</category>
</programme>
</tv>
php code:
$domtemp = new domDocument;
$domtemp->load("file.xml");
$fullfile = simplexml_import_dom($domtemp);
foreach($fullfile->programme as $program){
$category = $program->xpath('//category[@lang="en"]');
echo $category[0]."\n";
}
My Question is:
Why do i get only the category from the first entry in every loop pass?
Output:
information
information
Edit:
Ive worked around the problem with:
$domtemp = new domDocument;
$domtemp->load("file.xml");
$fullfile = simplexml_import_dom($domtemp);
foreach($sxe->programme as $program){
$program = simplexml_load_string($program->asXML());
$category = $program->xpath('//category[@lang="en"]');
echo "{$category[0]}\n";
but i still want to know why this doesnt work like i expected.
Greetings
BluBb_mADe