<?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>
私は上記のXMLデータファイルを持っています。私はchannel-name = "HR"セクションにタイトルをエコーしようとしています。したがって、エコーは「HR-TVにようこそ」である必要があります。SimpleXMLオブジェクトを表示中にエラーが発生しています
これは私がこれを実行すると、しかし、この
<?php
$picture_container = simplexml_load_file('data.xml');
echo $picture_container->[month-name[0]]->[channel-name[1]]->title;
?>
を行うための私のPHPコードは、このエラー パースエラーを取得です:構文エラー、予期しない「[」、期待識別子(T_STRING)または変数を( T_VARIABLE)や '{' または '$' はC:\ wamp64 \ WWW \ POC - ライン3
上ITTVの\ logic.phpは親切に助けて