xml xpath help
- Started
- Last post
- 3 Responses
- versa
i am really new to this, so be nice ;)
i am essentially trying to put all of a sites 'products' section into one xml file - then use the xml dom to get all of the attribute values, and node values out of the doc - no matter how deep the xml doc gets ( several sublevels )
something like this is starting to work:
$file = "products.xml";
$doc = domxml_open_file($file);
if (!$doc = domxml_open_file($file)) {
echo "Error while parsing the document\n";
exit;
}$root = $doc->document_element();
$xpc = xpath_new_context($doc);
$cats = xpath_eval($xpc, "//cat");
$subcats = xpath_eval($xpc, "//cat/subcat");
//$categories = $root->child_nodes();
//$subcategories = $root->$categories->child_nodes...foreach ($cats->nodeset as $categories) {
print $categories->get_attribute("titl...
}but this of course is only getting me the first, child node of the root which in this case is called 'cat' for category
beyond this tho, i don't know how, after looking at many examples, to full traverse the xml doc, to all of the children nodes, to retrieve all of the date, and store it into appropriate vars to echo into my html base file
anyone know of any clearly stated, more simple examples of this ? i am really confused at this point, but know that if i can get this working, it is going to be a way more organized approach
thx
- versa0
i'm desperate ovah heeere !
- instantok0
this is what i always used with php/xml...it makes all that stuff easier...im not great at php though so im not sure if this is what you are looking for:
- versa0
bummp