Link to home
Start Free TrialLog in
Avatar of brdrok
brdrok

asked on

Need help with XML

Hi,

I have an xml element that looks like the following:

<SQLQuery>
      <![CDATA[
            SELECT
                  P.Name,
      P.ID,
      P.Address,
     etc......

      FROM        
        Person P
      INNER JOIN Department D ON D.PersonID = P.ID
     etc.....
      WHERE    
        P.HireDate > { d '2002-01-01'})]]>
    </SQLQuery>


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();

thanks...


Avatar of Jens Fiederer
Jens Fiederer
Flag of United States of America image

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.
Avatar of brdrok
brdrok

ASKER

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.

thanks
ASKER CERTIFIED SOLUTION
Avatar of Jens Fiederer
Jens Fiederer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial