Anyone have any ideas how to resolve this? The single quote is throwing me for a loop.
$nodes = $xml->xpath("//item[contains(@catalog,'Billy's Blogs')]/title");
I've tried to escape it in various ways, all throwing errors:
$nodes = $xml->xpath("//item[contains(@catalog,'Billy\'s Blogs')]/title");
$nodes = $xml->xpath("//item[contains(@catalog,'Billy's Blogs')]/title");
Use whatever way there is in your language (I don't know PHP) to escape the quote character inside a quoted string, something like this:
$nodes = $xml->xpath("//item[contains(@catalog,\"Billy's Blogs\")]/title");
As salathe answered here, you cannot escape an apostrophe in XPath.
How about using quote along with ' and "? See example in here. notes = 'New Lapytop"s ;USB" MP3 player"'
精彩评论