Jump to content



Photo

C# Create XML, has extra slash

c# xml

  • Please log in to reply
6 replies to this topic

#1 James Rose

James Rose

    Software Developer

  • Tech Issues Solved: 1
  • Joined: 20-January 04
  • Location: New York City

Posted 24 June 2014 - 16:14

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




#2 +scumdogmillionaire

scumdogmillionaire

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 23-October 01
  • Location: Denver, CO
  • OS: Windows 8.1 Pro/Windows 8.1 RT
  • Phone: Nokia Lumia 920

Posted 24 June 2014 - 16:34

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



#3 OP James Rose

James Rose

    Software Developer

  • Tech Issues Solved: 1
  • Joined: 20-January 04
  • Location: New York City

Posted 24 June 2014 - 18:17

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

 

Yes.



#4 Eric

Eric

    Neowinian Senior

  • Tech Issues Solved: 13
  • Joined: 02-August 06
  • Location: Greenville, SC

Posted 25 June 2014 - 14:22

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.



#5 mastercoms

mastercoms

    Expert Microsoft Fanboy & C# Coder

  • Tech Issues Solved: 3
  • Joined: 21-May 13
  • Location: Marietta, Georgia
  • OS: W10 + Fedora 21
  • Phone: Lumia 928 WP8.1U1 Black

Posted 12 July 2014 - 08:01

What's the drGet function?



#6 articuno1au

articuno1au

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 20-March 11
  • Location: Brisbane, Australia

Posted 12 July 2014 - 08:29

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?



#7 mastercoms

mastercoms

    Expert Microsoft Fanboy & C# Coder

  • Tech Issues Solved: 3
  • Joined: 21-May 13
  • Location: Marietta, Georgia
  • OS: W10 + Fedora 21
  • Phone: Lumia 928 WP8.1U1 Black

Posted 12 July 2014 - 08:56

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

That's what I was thinking too.