all groups > dotnet xml > july 2004 >
You're in the

dotnet xml

group:

XML and carriage returns


RE: XML and carriage returns tim-kilostar
7/31/2004 4:33:01 AM
dotnet xml:
Hi Josh -

ASCII character 13 is the carriage return character - but in your XML you're using #13 which is the hexadecimal form for the number 19. This won't give you the results you're after. Instead use &13; (i.e., remove the # character) or &0d; to represent the carriage return.

Because this might have been a typo when you made your original post, I would also suggest that your also create an XmlTextReader object and supply that to the DataSet.ReadXml() method instead. This will at the very least allow you to experiment with the properies on the XmlTextReader class.

Hope this helps, or points you in the right direction.

--
Tim Roberts
Kilostar Solutions Ltd.


[quoted text, click to view]
XML and carriage returns Josh
7/31/2004 11:19:02 AM
Hi,

I'm using System.Data.DataSet.ReadXml to convert some xml from a webservice
to a DataSet. The xml looks like:

<?xml version="1.0"
encoding="UTF-8"?><root><prioritiesTable><description>blah blah&#13;blah
blah</description></prioritiesTable></root>

The important thing here is the &#13; which I beleive should be a single
carriage return. However when ReadXml has finished it has been converted to
what appears to be a carriage return and line feed. Which is a big problem
for me because it adds an extra character which inturn can cause a
constraint vialation in my database.

Is it doing it wrong? What can I do to change this behaviour??

please help!
thanks in advance
Josh

Re: XML and carriage returns Martin Honnen
7/31/2004 2:29:35 PM


[quoted text, click to view]

No, in XML numeric character references in the form
&#dddd;
(d meaning 0..9) uses decimal notation so
&#13;
is the Unicode character with character code 13 and that is the carriage
return character.
If you wanted to use hexadecimal notation then you need to use
&#xdd;
(d meaning 0..9A..F) for instance for the carriage return you need
&#xD;
see the XML specification
http://www.w3.org/TR/REC-xml/
in particular
http://www.w3.org/TR/REC-xml/#sec-references

--

Martin Honnen
http://JavaScript.FAQTs.com/
Re: XML and carriage returns Oleg Tkachenko [MVP]
7/31/2004 8:54:06 PM
[quoted text, click to view]

XML treats end-of-line characters semantically, not syntactically, thus
requiring normalization of such characters for the platform
independence's sake.
According to the XML spec:
"To simplify the tasks of applications, the XML processor MUST behave as
if it normalized all line breaks in external parsed entities (including
the document entity) on input, before parsing, by translating both the
two-character sequence #xD #xA and any #xD that is not followed by #xA
to a single #xA character."
And when XML is being serialized to bytes, #xA is usually serialized in
platform-dependent way, which is #xD#xA on Windows.

--
Oleg Tkachenko [XML MVP]
Re: XML and carriage returns Josh
7/31/2004 10:15:05 PM
Hi, thanks for your reply Tim.

I'm probably more confused though! lol
I didnt write the conponet that supplied the xml containing "&#13;". But I
know in the DB where it got the data from it was a carriage return, I
inserted myself using ctrl M. So is 'and hash one there' a valid character
for utf-8 encoding? I thought nothing below 20 other than carriage return
and a couple of others was legal in utf8? If its ascii 19 thats character
DC3 which defenetly isnt what its meant to be.
Is it perhaps a html escape sequence that isnt strictly xml?

Any ideas would be much appreaciated.
thanks
Josh


[quoted text, click to view]
you're using #13 which is the hexadecimal form for the number 19. This won't
give you the results you're after. Instead use &13; (i.e., remove the #
character) or &0d; to represent the carriage return.
[quoted text, click to view]
would also suggest that your also create an XmlTextReader object and supply
that to the DataSet.ReadXml() method instead. This will at the very least
allow you to experiment with the properies on the XmlTextReader class.
[quoted text, click to view]

AddThis Social Bookmark Button