I am having problems with the xml file, I found many examples / tutorials on the Internet and on this site, but I do not see one like this:
I have an XML file, for example:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<items item1="1" item2="2" item3="3" item4="4"/>
<items item1="1" item2="2" item3="3" item4="4"/>
<items item1="1" item2="2" item3="3" item4="4"/>
</root>
I have not seen the data is the same as before, and when I try:
<?php
$obj = simplexml_load_string("sample.xml");
print_r($obj);
?>
I get an error message:
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Start tag expected, '<' not found
I launched the xml file through a check at www.xmlvalidation.com and everything returns, am I missing something?
I am looking to be able to echo element attribute values in a while loop.
source
share