Xml file:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Row>
<Cell ss:Index="1">
<Data ss:Type="String">Продукт1</Data>
</Cell>
</Row>
Открываю
$filename = dirname(__FILE__)."/newXMLDocument.xml";
if (file_exists($filename)) {
$xml = simplexml_load_file($filename);
print_r($xml);
} else {
exit('Failed to open file');
}
Получаю warnings:
": namespace error : Namespace prefix ss for Index on Cell is not defined",
Warning: simplexml_load_file(): ^
,
Namespace prefix ss for Type on Data is not defined
,
simplexml_load_file(): <Data ss:Type="String">Продукт1</Data>
Тем не менее выводит:
SimpleXMLElement Object ( [Row] => Array ( [0] => SimpleXMLElement Object ( [Cell] => SimpleXMLElement Object ( [@attributes] => Array ( [Index] => 1 ) [Data] => Продукт1 ) ) [1] => SimpleXMLElement Object ( [Cell] => SimpleXMLElement Object ( [@attributes] => Array ( [Index] => 2 ) [Data] => Продукт2 ) ) [2] => SimpleXMLElement Object ( [Cell] => SimpleXMLElement Object ( [@attributes] => Array ( [Index] => 3 ) [Data] => Продукт3) )
Как убрать ошибки? Где объявить ss?