473,395 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

XML and carriage returns

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 blah
blah</description></prioritiesTable></root>

The important thing here is the 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
Nov 12 '05 #1
4 18636
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.
"Josh" wrote:
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 blah blah</description></prioritiesTable></root>

The important thing here is the 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

Nov 12 '05 #2
Hi, thanks for your reply Tim.

I'm probably more confused though! lol
I didnt write the conponet that supplied the xml containing " ". 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
"tim-kilostar" <ti*********@discussions.microsoft.com> wrote in message
news:9B**********************************@microsof t.com...
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.
"Josh" wrote:
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

blah
blah</description></prioritiesTable></root>

The important thing here is the

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

Nov 12 '05 #3


tim-kilostar wrote:
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.


No, in XML numeric character references in the form
&#dddd;
(d meaning 0..9) uses decimal notation so

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/

Nov 12 '05 #4
Josh wrote:
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 blah
blah</description></prioritiesTable></root>

The important thing here is the 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.


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]
http://blog.tkachenko.com
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: yawnmoth | last post by:
so... i'm trying to remove all carriage returns in the input i get from GET, and am trying to replace them with three dots... however, this never seems to work... i'm still getting carriage...
4
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to...
12
by: Nimmy | last post by:
Hi, I have a data file and I want to remove Carriage returns. Any one has any C code/program which does this? I am working on Windows XP machine.....I don't have access to UNIX machine. But I...
2
by: Matt Mercer | last post by:
Hi all, I am having a frustration problem, and I have read about 25 newsgroup postings that do not have a satisfying answer :) The problem appears to be common where carriage returns are lost...
8
by: TheDude5B | last post by:
Hi, I have some data which is stored in my MySQL database as TEXT. when the data is entered in, it has some carriage returns in it, and this can be seen when querying the data using MySQL Query...
7
by: mattrapoport | last post by:
I have a page with a div on it. The div displays a user comment. When the user logs into this page, their current comment is pulled from a db and displayed in the div. The user can edit the...
4
by: Tony Girgenti | last post by:
Hello. When i look at a web form in design view, i have the option to view the HTML. Some of the HTML code is in one long string and hard to read. Is it OK to put in carriage returns and...
6
by: shajias | last post by:
Hi, I am having a xml code like this <name> I am having a carriage return here. Second line with carriage return. This is the last line. </name>
2
by: GregBeagle | last post by:
Windows XP I have a simple form from which I want to generate an email with the contents of the form. I use carriage returns to format the content for readability. When I test it on my computer...
0
by: markus.shure | last post by:
Hi, I'm noticed a problem testing a JAX-WS client with a WSE server. The JAX-WS client adds carriage returns to a SOAP header element that is signed. This causes the WSE server to raise an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.