473,703 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML and carriage returns

Hi,

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

<?xml version="1.0"
encoding="UTF-8"?><root><prio ritiesTable><de scription>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 18694
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.Dat aSet.ReadXml to convert some xml from a webservice
to a DataSet. The xml looks like:

<?xml version="1.0"
encoding="UTF-8"?><root><prio ritiesTable><de scription>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*********@di scussions.micro soft.com> wrote in message
news:9B******** *************** ***********@mic rosoft.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.Dat aSet.ReadXml to convert some xml from a webservice to a DataSet. The xml looks like:

<?xml version="1.0"
encoding="UTF-8"?><root><prio ritiesTable><de scription>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.Dat aSet.ReadXml to convert some xml from a webservice
to a DataSet. The xml looks like:

<?xml version="1.0"
encoding="UTF-8"?><root><prio ritiesTable><de scription>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
13035
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 returns... here's my script... any ideas as to what's wrong?: <?php
4
7315
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 use: 'replace carriage returns with BRs comment=Replace(comment, chr(13), "<br>") but obviously net.! The <pre> tag doesn't sem to help either as the embedded return is
12
5611
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 need to send this data file to the Unix machine once I remove the carriage retunrns from my XP machine. Thanks
2
2335
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 when pulling data from an SQL database. The thing that frustrates me the most, is that when I use Enterprise Manager, the carriage returns ARE THERE. It looks fine until I pull it out.
8
2221
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 Browser. I want to then display this text within <p> tags when requested from the database. However, the test is formatted without the carriage returns.
7
11193
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 comment through a pop-up that contains a textarea. When the user hits OK on the pop-up, the text in the textarea is sent to a function on the main page. The function inserts the text into the div's text node. Please don't ask why I'm making this...
4
1678
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 blank lines in the HTML so that is is easier to read ? I'm not talking about changing the HTML code logic, just the readability of it.
6
13538
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
4651
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 the email generated by getURL("mailto..") is fine in my email client. Carriage returns are kept etc and shows how I want it. However when I upload it to the server and run it on the web, the carriage returns are stripped out of the text and all...
0
1492
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 error: "The signature or decryption failed". If the carriage returns are removed, the same web service call is successful. I tried replicating the situation with a WSE client. I created a WSE client that adds a SOAP header element that contains a...
0
8759
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9251
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7872
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3125
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2453
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2069
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.