flibbles / tw5-xml

XML tools for Tiddlywiki5: import/xport, rendering, parsing wth XPath and CSS Selectors
BSD 3-Clause "New" or "Revised" License
10 stars 1 forks source link

Ampersand breaks templates? #3

Open Wattaged opened 4 years ago

Wattaged commented 4 years ago

Hi Flibbles Still enjoying your very useful plugin, thanks. Tried a template today and couldn't get it to work, after filtering through the xml content it seems the '&' ampersand was the problem. Tested and reproduced it on your demo site on 'Examples/Rendering/Process.xml' - if you put an & after Martha the template breaks. I've got urls in my xml content with '&' in so thought I'd raise it in case there was an easy fix. Otherwise still working well, thanks a lot.

flibbles commented 4 years ago

Putting plaintext ampersands in text (<book>Strunk & White</book>) is illegal in XML. If you need to do it, there are two ways:

<book>Strunk &amp; White</book>

or

<book><![CDATA[Strunk & White]]></book>

tw5-xml can handle either of these cases.

Unfortunately, it's not great about telling you why any particular XML document is bad, so sorry you had to take time to track this down. Problem is, the DOM engines on all the different browsers (and NodeJS) all handle erroneous XML in different ways, so that's a bag of cats I've been afraid to open.

Wattaged commented 4 years ago

Thanks for the explanation and remedies. Not looking to cause you work, leave those cats in the bag and I'll try your solutions. Thanks again.