Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML parser skips mutiple whitespaces while parsing a xml list element

bhavana radhakrishnan
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<p>I have a list like {“A”,””,”C”}.I serialise it into a text file as a xml list element . The serialized string turns out to be “A C” (two spaces between A and C)
<p>But XML SAX parser parses it to “A C” with a single space between them(consolidates mutiple spaces to one space)
<p>In my program I take the parsed string(A C) and apply a java split function on it. It gives me a list {"A","C"} .The empty space has been dropped.
After i did some googling i found that
<li>XML SAX parser parses:
All non-space characters (tab and new-line) are translated into a space character, and all multiple space characters are consolidated
into a single space.</li>
<li>And also The restriction <whitespace value=”preserve”> which is the support given by the XML to preserve whitespaces will work only on the string based elements and not on <xsd:list> element</li>
Can you please confirm whether the above information is correct?Is there any parser setting to preseve the mutiple whitespaces in a list element while parsing. I am using a Xerces SAX parser.
<p> My work is held up cause of this issue. Can anyone please help out?
<p>Thanks in advance!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic