Escaping single and double quotes for use with XPath queries in PHP

19th August, 2011Insights

I’ve been working with the Basecamp API to plugin our IRC bot that we use for time tracking and I’m astounded to learn that escaping single and/or double quotes for XPath queries in PHP does not have a well documented, best practices solution.

In fact, it seems as though this is not peculiar to PHP. I took a look around and found this excellent article by “Kushal” (s/he doesn’t have his full name on his blog):

http://kushalm.com/the-perils-of-xpath-expressions-specifically-escaping-quotes

I’ve produced a PHP solution for the general escaping/concatenation problem:

https://gist.github.com/1155973

Anyone got a better/more elegant solution? I’m always a big fan of code golf 🙂

Read More Posts

Can DialPad be used for SMS and MMS in Australia?

DailPad is a great VoIP app, but in Australia it's sadly lacking the ability to do SMS and MMS messages to mobile numbers outside the app. Perhaps because DialPad originated in the US, the need to build the SMS and MMS features for the Australian market has never made...

Can RingCentral be used for SMS and MMS in Australia?

RingCentral is a very sophisticated VoIP platform that you can use for your business telephony needs. In the US and Canada, it also supports SMS and MMS messaging directly from within the app. In Australia, however, this is not available. RingCentral users in...

Does 8×8 work for SMS and MMS in Australia?

8x8 is a provider of VoIP and messaging products that originated in the US. As such, its messaging solutions are very US centric and one of the features that hasn't made it to Australia is the ability to do SMS and MMS messages from the 8x8 app. 8x8 users are able to...

Free 12 week email course:

Don't distribute your office
How to make your remote team more effective than any in person team could ever be