We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › xml libary CDATA
Page Index Toggle Pages: 1
xml libary CDATA (Read 459 times)
xml libary CDATA
Apr 5th, 2008, 9:26pm
 
I try to load a xml file from the colourLovers API using the processing xml library but it fails on the following line:

Code:

<url><![CDATA[http://www.colourlovers.com/color/FF262D/electric_Miles]]></url>


with this error message: "XML Parse Exception during parsing of a colors element at line 23: Expected: Comment or Element"

Can someone explain whats wrong here and if there is a way to handle CDATA section. Does someone know if proXML is an opinion?
Re: xml libary CDATA
Reply #1 - Apr 12th, 2008, 11:06pm
 
Ok, after digging deeper I found out that it wasn't the url line but this:  

Code:

<description><![CDATA[]]></description>


It seems that the xml library can't handle empty CDATA, cause adding a simple SPACE as content it will pass.

After digging in the source I think it's a bug and I use this hack to deal with:

Code:

String[] s = loadStrings(url);
StringBuffer buf =new StringBuffer();
for (int i = 0; i < s.length; i++) {
buf.append(s[i].replaceAll("CDATA.]", "CDATA[ ]"));
}
XMLElement xml = new XMLElement(buf.toString());

Page Index Toggle Pages: 1