Bartman
Новичок
Доступ к XML через DOM
Здравствуйте!
Пытаюсь получить доступ к XML документу через DOM.
Вот сам XML-документ:
<?xml version="1.0" encoding="windows-1251" ?>
<info>
<status value="900"/>
<topics>
<topic title="TEST ARTICLE" url="http://www.test.com"/>
</topics>
<additional_info>
Text1
Text2
Text3
</additional_info>
</info>
Получить доступ к элементу <status> получилось:
Подскажите, пожалуйста, а как можно получить доступ к элементам <topic> и <additional_info>?
Здравствуйте!
Пытаюсь получить доступ к XML документу через DOM.
Вот сам XML-документ:
<?xml version="1.0" encoding="windows-1251" ?>
<info>
<status value="900"/>
<topics>
<topic title="TEST ARTICLE" url="http://www.test.com"/>
</topics>
<additional_info>
Text1
Text2
Text3
</additional_info>
</info>
Получить доступ к элементу <status> получилось:
PHP:
$dom = domxml_open_mem($contents);
$root = $dom->document_element();
$root_child = $root->child_nodes();
for ($i = 0; $i < count($root_child); $i++)
{
if ($root_child[$i]->node_name()=='status')
{
$stat = $root_child[$i]->get_attribute('value');
}
}