472,984 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,984 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 18236
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.