I work with PHP and Xpath and when save data i need insert unique id.
As in SQL auto increm.
How make this in Xpath?
File:
<info>
<id>1</id>
<name>test</name>
</info>
<info>
<id>2</id>
<name>some</name>
</info>
....
<id>5</id>
<name>testttt</id>
I believe it would be something like:
So, with PHP’s DOMDocument per example:
The above assumes that the last node has the greatest ID.
In your case, it is impossible to compute the next ID with XPath alone. XPath 2.0 provides the
maxfunction to do that:However, XPath 2.0 is not yet supported in PHP built-in libraries.