Sign in to follow this  

C# Create XML, has extra slash

Recommended Posts

James Rose    38

Hello gang,

 

I am creating an xml document from data from a database.  However when I write them as an attribute it gets an extra slash

<Trend Ident=\"1\" Info=\"Test1\" />

The database has only "Test1"

 

The code is as follows:

                while (drGet.Read())
                {
                    XmlElement Trend = xmlTrending.CreateElement("Trend");
                    Trend.SetAttribute("Ident", drGet.GetInt32(0).ToString());
                    Trend.SetAttribute("Info", drGet.GetString(1));
                    Trends.AppendChild(Trend);
                }

Thanks

Share this post


Link to post
Share on other sites
scumdogmillionaire    175

are you talking about the escape in front of the quote?

Share this post


Link to post
Share on other sites
James Rose    38

are you talking about the escape in front of the quote?

 

Yes.

Share this post


Link to post
Share on other sites
Eric    1,512

Where are you seeing the escape slashes? They will show up in the data inspector while debugging but should be output as text without them.

  • Like 2

Share this post


Link to post
Share on other sites
mastercoms    434

What's the drGet function?

Share this post


Link to post
Share on other sites
articuno1au    1,264

I believe drGet is a data row object (or a collection of DataRow).

 

Depending on the DB provider, is it possible you're being provided escape characters in the returned data?

  • Like 1

Share this post


Link to post
Share on other sites
mastercoms    434

you're being provided escape characters in the returned data?

That's what I was thinking too.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.