Need help with XML

Posted on 2007-03-19
Last Modified: 2011-09-20

I have an xml element that looks like the following:


        Person P
      INNER JOIN Department D ON D.PersonID = P.ID
        P.HireDate > { d '2002-01-01'})]]>

When I attempt to parse the <SQLQuery> element, my text looks like the following:

"<![CDATA[\r\n\t\tSELECT\r\n\t\t      P.Name,\r\n     etc........."

this is how I attempt to extract the text of my SQLQuery element.
string sql = dsNode.SelectSingleNode("SQLQuery").InnerXml.Trim();


Question by:brdrok
  • 2
LVL 23

Expert Comment

by:Jens Fiederer
ID: 18750781
It does not look to me like you have a problem (if you do, tell us, please!)

If you are worried about the \r \n\t characters in your string, those simply represent the carriage returns, linefeeds and tabs in the text you provided.  That is as it should be.  You can always replace those with spaces if you want everything on one line.

Author Comment

ID: 18751090
Heya Jens,

the thing is that I am going to use it as part of a sql query, thus, characters such as "\t\r\n" or CDATA is invalid.

For the time being, I am using the Replace() function, but I was hoping that there is a better way of doing it.

LVL 23

Accepted Solution

Jens Fiederer earned 500 total points
ID: 18753910
Sounds reasonable.  The OTHER option is to NOT put those characters in there in the first place, if the XML is under your control.

I.e.,  instead of


<![CDATA[SELECT P.Name, P.ID, P.Addres


Trying to do fancy formatting inside a CDATA sticks you with unwanted formatting in the output!

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
New to SOAP and need some direction 10 46
How to get the web content with different encodings 2 28
Error on link 14 38
C#.NET and microsoft certification. 3 34
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Sending a Secure fax is easy with eFax Corporate ( First, just open a new email message. In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now