XPATH request with one quote

Anyone have any ideas how to solve this? A single quote throws me in a loop.

$nodes = $xml->xpath("//item[contains(@catalog,'Billy Blogs')]/title"); 

I tried to avoid this in many ways, all throwing errors:

 $nodes = $xml->xpath("//item[contains(@catalog,'Billy\ Blogs')]/title"); $nodes = $xml->xpath("//item[contains(@catalog,'Billy's Blogs')]/title"); 
+4
source share
3 answers

Use any method that exists in your language (I don't know PHP) to avoid the quote character inside the quoted string , something like this:

 $nodes = $xml->xpath("//item[contains(@catalog,\"Billy Blogs\")]/title"); 
+3
source

Since salathe answered here , you cannot escape the apostrophe in XPath.

+3
source

How about using a quote with ' and ' . See an example here . notes = 'New Lapytop"s ;USB" MP3 player"'

0
source

Source: https://habr.com/ru/post/1332237/


All Articles