<?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>
I have the above XML data file. I am trying to echo the title in the channel-name = "HR" section. So,the echo should be ' Welcome to HR-TV.
This is my php code for doing this
<?php
$picture_container = simplexml_load_file('data.xml');
echo $picture_container->[month-name[0]]->[channel-name[1]]->title;
?>
However, when I run this is get this error Parse error: syntax error, unexpected '[', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\wamp64\www\POC - ITTV\logic.php on line 3
Kindly help