Sign in to follow this  
Followers 0

C# Create XML, has extra slash


7 posts in this topic

Posted

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

Posted

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

Share this post


Link to post
Share on other sites

Posted

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

 

Yes.

Share this post


Link to post
Share on other sites

Posted

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.

2 people like this

Share this post


Link to post
Share on other sites

Posted

What's the drGet function?

Share this post


Link to post
Share on other sites

Posted

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?

1 person likes this

Share this post


Link to post
Share on other sites

Posted

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  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.