Help with ampersand in xml

Andre Garzia andre at
Thu Oct 18 17:31:25 EDT 2012


In theory you can't have ampersands in XML because it assumes it is an
entity. You can try using & but it shouldn't work because XML is not
HTML. I will tell you my dirty trick for dealing with ampersands. Its a
very boring trick.


I replace every ampersand with something like:

  replace "&" with "#AMPERSAND#" in tXML

This way, the XML routines work just fine and when presenting some data
that may contain an ampersand, I replace the "#AMPERSAND#" back.

This is a tedious trick but it works, there is also trick #2...


Add & to your XML entities with a declaration with <!ENTITY ... >.

Those tricks really depend on the parser. IIRC LiveCode uses libxml2 which
is a pretty good and standard parser. It may allow you to replace your &
with &


On Thu, Oct 18, 2012 at 12:35 PM, Chris Sheffield <cmsheffield at>wrote:

> For all you xml experts out there. Hoping someone has the answer for
> this...
> I need to use an ampersand character (&) in xml. It's in a company name
> like Levi Strauss & Co. Everything I can find on the topic says to use the
> entity reference "&", but this doesn't seem to be working. I just end
> up with a blank space. Does anyone know how to make this work?
> I'm beginning to think I've run into a bug in the LiveCode xml parser. I'm
> currently using the revXMLNodeContents() function. Should I be using some
> other function?
> Thanks,
> Chris
> _______________________________________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:

-- -- All We Do Is Code. -- minimalist url shortening service.

More information about the Use-livecode mailing list