The XML document that comes out of the API is not validated and break when fields contain ampersands (&)

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered

I've noticed that the XML document that comes out of the API is not validated.  Basically if you have any ampersands in a text field you'll get a broken XML document.  Bringing this up with the Quickbase support team I was not able to get across to them that it was being produced from their API.  They kept saying it was the XML converter at issue.  So until they decide that it is a bug and address it I've found a regex/replace method you can run on the document.

Below is a Javascript example.  You can utilize the language appropriate replacement function.  Run it through twice to catch any double ampersands that may be in a field (&&). 

var regex = /&([^;\W]*([^;\w]|$))/ig;
var replacement = "&$1";
xml = xml.replace(regex, replacement).replace(regex, replacement);

None of the other special characters are escaped either but they don't seem to break converters such as xml2json.min.js.
Photo of Jeremy

Jeremy

  • 0 Points

Posted 4 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,224 Points 20k badge 2x thumb
I think there might be other various problems with the validation but I rarely used the XML response as a XML document requiring validation. Working client side with jQuery you use CSS Selectors (not XPATH Selectors) against the XML Response which is just treated as the DOM context being the second argument of $( *, *):

$(<selector>, xml).<method>(...)

I fell deep into the XML Bunny Hole and learned my lesson (use JSON, HTML, CSS, and JavaScript and avoid XMLSchema, XMLValidation, XML-FO etc).