Search code examples
htmlxmlcdata

xml cdata not allowing html


So from what I understand of the CDATA tags on an XML document, it's meant to allow HTML tags inside it to function as they normally would. I am working with a website template here that uses XML files, and while editing one of the documents to add a href or image to it, I rather get a string. Here's the code, if you can help me that would be greatly appreciated.

I have tried modifying the code to use the < / > that it seems to want to suggest in the output text, but that doesn't help either. If anybody can explain or link me to relevant information, or both, it would be amazing =)

    <?xml version="1.0"?>
    <xmldata section="Address">
<content>
<image src="resources/images/streetmap1.png" />

<bodytext><![CDATA[Shop 6, 106 Foster Street
     Dandenong, 3175

     Street Map:
     <image src="resources/images/streetmap1.png" />




]]></bodytext>
</content>  
    </xmldata>

EDIT - Supplying accompanying .js file.

http://pastebin.com/Td2EYiKH


Solution

  • So from what I understand of the CDATA tags on an XML document, it's meant to allow HTML tags inside it to function as they normally would.

    No. It is so that characters with special meaning in XML (such as <) can be included as data without escaping.

    Here's the code

    You need to look at the code that transforms the XML data into the HTML content. You haven't shared that with us.

    <image src="resources/images/streetmap1.png" />

    The HTML element is img not image and it should have an alt attribute.