Answer the question
In order to leave comments, you need to log in
How to create a tree of loadable nodes from a random XML file?
Good time of the day.
I'm having difficulty creating a dropdown tree from a random XML file by loading nodes via ajax by clicking on them.
The whole problem is that the file was parsed using jQuery or PHP, I don’t know the exact structure, the name of the tags and the depth of nesting, so it’s impossible to sort through foreach, getElementsByTagName or through attributes. More precisely, if I know the entire structure for the current file through Simplexml,
$xml = simplexml_load_file("sample.xml");
$json = json_encode($xml);
$array = json_decode($json,TRUE);
Answer the question
In order to leave comments, you need to log in
I'm not counting on a TOP1 answer, but I think it's worth seriously considering using XPath . In theory, you can easily identify the clicked node, pass it to the XPath server, and that in turn, using XPath, return exactly what you need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question