benibela / xidel

Command line tool to download and extract data from HTML/XML pages or JSON-APIs, using CSS, XPath 3.0, XQuery 3.0, JSONiq or pattern matching. It can also create new or transformed XML/HTML/JSON documents.
http://www.videlibri.de/xidel.html
GNU General Public License v3.0
681 stars 42 forks source link

Allow escaping of quotes #5

Closed Fuzzyma closed 8 years ago

Fuzzyma commented 8 years ago

I see myself often want to use something like this:

xidel foo.htm -e 'join(//something, "\",\""')
                                   --^^-^^--note these

Basically joining stuff together in csv format which requires quoted strings. However: xidel fails when using doublequotes there so the escaping does not work. Is there a workaround or is there a chance that escaping gets added to xidel?

PS: Awesome tool!

benibela commented 8 years ago

It has escaping according to the XPath/XQuery standard ( https://www.w3.org/TR/xquery-31/#id-literals ):

Basically you need to write "" rather than \".

In XQuery mode you can also write "

I was not sure which mode should be the default, so I made a survey

In XPath/XQuery 3.1, which I have not yet implemented, there is an additional string type surrounded by :

 ``[ ]``