This is valid XPath in Javascript:

```
id("priceInfo")/div[@class="standardProdPricingGroup"]/span[1]

```

And this turned into valid PHP XPath to be used with DOMXPath->query() is

```
//*[@id="priceInfo"]//div[@class="standardProdPricingGroup"]//span[1]

```

1. do you know any libraries or custom components that already do this transformation?
2. do you know available documentation that lists the two syntax differences?

My main concern is that there could be a lot of differences, and I am looking to identify these differences, and I have problems to identify these. 

The question could be put also in different way: **Since Javascript can have different valid XPath formats, how to normalize them to work with the PHP.**

One of the updates also mention that the id() function is valid XPath if there is a valid DTD that contains this definition. I don't have power over the input DTD, and if there is a way to find a solution that works without any specific DTD it would be awesome.

**Update:**

I want to transform the first format into the second with an algorithm. My input is the first one and not the second one. Can't change this.

As @Nison Maël pointed out, the 2nd format is valid Javascript XPath as presented here: <http://jsbin.com/elatum/2/edit> this unfortunately just adds to the problem of Javascript XPath "fragmentation".

@salathe pointed out that the valid Javascript XPath query works fine in PHP if the input documented has valid DTD ( @Dimitre Novatchev mentioned this in a comment, but overlooked the importance). Unfortunately I don't have control of the input DTD, so now I have to investigate a way to overcome this, or to find a solution that works even without valid DTD.