Click here to Skip to main content
15,867,316 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a xml file like this:
XML
<?xml version="1.0" encoding="UTF-8"?>
<version_logs>
	<version_log id="0.8.351.639">
		<version>0.8.351.639</version>
		<release_date>May 2014</release_date>
		<logs>
			<log>Minor bug fixes</log>
			<log>Increase compatibility</log>
			<log>Better user</log>
			<log>New languages</log>
		</logs>
	</version_log>
	<version_log id="5454.54.464.3">
		<version>5454.54.464.3</version>
		<logs>
			<log>fffff</log>
			<log>fdgdgsdgsdgsd</log>
			<log>ererererer</log>
			<log>lllllll</log>
			<log>lllllll</log>
			<log>lllllll</log>
			<log>lllllll</log>
		</logs>
	</version_log>
</version_logs>


I am trying to get all the information of the version_log tag by it's "id". By using something like this:
PHP
$nodes = $xml->xpath('//version_log/version[contains(., "5454.54.464.3")]');


Which only give me the version tag value and not the rest of the information.

What I am missing here?
Posted

1 solution

Just be logical. You receive the version only because this is exactly what your requested in your query. "The rest on information", by the true meaning of these words, should mean the whole XML, but you already have it. :-)

You just need to formulate what you want at lest for yourself. Need the child nodes of the node with the version? Okay, read the children of this node. And so on.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900