Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Line breaks in XML

Avatar

Former Community Member
Why does the exported XML file look like this:<br /><blockquote><br /> ><CITY>MyCity</CITY<br><br /> ><STATE>MyState</STATE<br><br /> ><POSTAL>MyPostal</POSTAL<br><br /> ><CTRY>USA</CTRY<br /></blockquote><br />etc.<br /><br />instead of<br /><blockquote><br /> <CITY>MyCity</CITY><br><br /> <STATE>MyState</STATE><br><br /> <POSTAL>MyPostal</POSTAL><br><br /> <CTRY>USA</CTRY><br /></blockquote><br />etc.?<br /><br />That is, carriage returns are being inserted in odd places which makes the file hard (for a human, at least) to read. Is there a reason that it does this and can I change it? <br /><br />Thanks.
2 Replies

Avatar

Former Community Member
That's a good question and I asked about that myself at one point. It does seem odd, but the reason it's done that way is for compatibility.



There's some case where we have XML with no line breaks between the elements, and when filled in, this can result in an XML file that has on line breaks, just one incredibly long line. Some tools just can't deal with incredibly long lines. I don't remember the details but this was a problem we ran into.



If you insert a carriage return like this:



<a>foo</a>

<b>foo</b>



...then you've actually added a carriage return to the document. If you add the carriage return inside a tag, it's not - it's ignored. So that was the only place we could safely insert line breaks to not break tools that couldn't handle the whole XML file being on one line.



Normally people consuming XML are doing it through some toolkit that's parsing the XML and just giving them the data it contains, so this is transparent to them. If you're reading the XML like a text file, you might want to consider using XSLT or some other technology to parse the XML and generate a simpler format for you to read - there's no guarantee this will not change at some point.



--

SteveX

Adobe Systems