php - Xpath find a unique selector -


I am looking to parse an html page for a predefined string and then a unique reference to that place I am preparing. I have come so far with the help of 'wikikan' .. but this is not working very well.

  $ d = newdomdocument (); $ D & gt; LoadXML ($ XML); $ X = new DOMXPath ($ d); $ Result = $ x-> Rate ("// text () [[(., 'STRING')] / ancestor :: * / @ id"); $ Unique = null; ($ I = $ result-> Length-1; $ i> = 0 & amp; amp; $ item = $ result-> Item ($ i); $ i -) {if ($ x -> gt; Query ("// * [@ id = '". Addlashes ($ item- & gt; values). "']") -> gt; length == 1) {echo is 'unique ID' $ Item- & gt; Value "\ n". $ Unique = $ item- & gt; Values; break; }} If 'is_null (unique $)' 'no unique ID was found';   

__ edit _

Let me explain this problem again I am looking to create an html parser which can parse a page and find a unique string. Then I need to find a unique place holder for that location so that when the data on the website changes, I can get new data. Wrikken has helped me to find the string yet ... Unfortunately the above code is not getting a unique CSS selector properly.

Not sure that this is your problem, but I normally have to do the first part more than that :

// * [in [text (), 'STRING']] / ancestors: * / / id

Comments