<?xml version="1.0" encoding="UTF-8"?>
<TVchannel>
<month-name month="September">
<channel-name name="IT">
<title>Welcome to IT-TV</title>
<image-no-1></image-no-1>
<image-no-2></image-no-2>
<image-no-3></image-no-3>
<image-no-4></image-no-4>
<image-no-5></image-no-5>
</channel-name>
<channel-name name="PTG">
<title>Welcome to PTG-TV</title>
<image-no-1></image-no-1>
<image-no-2></image-no-2>
<image-no-3></image-no-3>
<image-no-4></image-no-4>
<image-no-5></image-no-5>
</channel-name>
<channel-name name="HR">
<title>Welcome to HR-TV</title>
<image-no-1></image-no-1>
<image-no-2></image-no-2>
<image-no-3></image-no-3>
<image-no-4></image-no-4>
<image-no-5></image-no-5>
</channel-name>
</month-name>
<month-name month="October">
<channel-name name="IT">
<title>Welcome to IT-TV</title>
<image-no-1></image-no-1>
<image-no-2></image-no-2>
<image-no-3></image-no-3>
<image-no-4></image-no-4>
<image-no-5></image-no-5>
</channel-name>
<channel-name name="PTG">
<title>Welcome to PTG-TV</title>
<image-no-1></image-no-1>
<image-no-2></image-no-2>
<image-no-3></image-no-3>
<image-no-4></image-no-4>
<image-no-5></image-no-5>
</channel-name>
<channel-name name="HR">
<title>Welcome to HR-TV</title>
<image-no-1></image-no-1>
<image-no-2></image-no-2>
<image-no-3></image-no-3>
<image-no-4></image-no-4>
<image-no-5></image-no-5>
</channel-name>
</month-name>
</TVchannel>
Ich habe die obige XML-Datei. Ich versuche, den Titel in der Channel-Name = "HR" -Abschnitt zu echo. Das Echo sollte also lauten: "Willkommen bei HR-TV.Fehler zeigt SimpleXML-Objekt
Dies ist mein PHP-Code, dies zu tun
<?php
$picture_container = simplexml_load_file('data.xml');
echo $picture_container->[month-name[0]]->[channel-name[1]]->title;
?>
Allerdings, wenn ich dies ausgeführt ist erhalte diese Störung Parse error: syntax error, unerwartet '[', erwartete Kennung (T_STRING) oder Variable (T_VARIABLE) oder '{' oder '$' in C: \ wamp64 \ www \ POC - ITTV \ logic.php on line 3
helfen freundlicher