converting the xml to string

Hi Everyone,

I am constructing an xml file, but when I try to read it there are some 
extra slashes in the output. Can anoyone tell me why there are some extra 
slashed and can i send the file to web service with those extra slashes. 
below I am constructing the document


StringWriter sWriter;
SqlDataReader dr;

dr = SqlHelper.ExecuteReader(connectionString,"SP_UsersData_Get");
XmlTextWriter w;
sWriter = new StringWriter();
//w = new XmlTextWriter("C:/text.txt", System.Text.Encoding.UTF8);
w= new XmlTextWriter(sWriter);

w.Formatting=Formatting.Indented;
w.Indentationfiltered=2;
w.WriteStartDocument(true);
w.WriteStartElement("test");
w.WriteStartElement("system");
w.WriteAttributeString("id", "UML");
w.WriteElementString("version", "1.0");
w.WriteStartElement("configuration");
w.WriteElementString("update_password","True");
w.WriteEndElement();
w.WriteStartElement("users"); 
while(dr.Read())
{
w.WriteStartElement("user");
w.WriteElementString("firstname", dr["first_name"].ToString());
w.WriteElementString("lastname", dr["last_name"].ToString());
w.WriteElementString("email", dr["email"].ToString());
w.WriteElementString("loginid", dr["Login"].ToString());

w.WriteElementString("status", "A");
w.WriteStartElement("roles");
w.WriteStartElement("role");
w.WriteString("Agent");
w.WriteStartElement("groups");
w.WriteStartElement("group");
w.WriteElementString("path", "Services/irvine/" + 
dr["supervisor"].ToString());
w.WriteEndElement();
w.WriteEndElement();
w.WriteEndElement();
w.WriteEndElement();
w.WriteStartElement("relations");
w.WriteStartElement("relation");
w.WriteElementString("type", "UML");
w.WriteElementString("externalid", dr["Login"].ToString());
w.WriteEndElement();
w.WriteEndElement();
w.WriteEndElement();
}
w.WriteEndElement();
w.WriteEndDocument();
w.Close();


}

When I do sWriter.ToString , It gives me an output file like below:
"<?xml versionfiltered=\"1.0\" encoding=\"utf-16\" 
standalone=\"yes\"?>\r\n<a>\r\n <system id=\"UMA\">\r\n 
<version>1.0</version>\r\n <configuration>\r\n 
<update_password>True</update_password>\r\n </configuration>\r\n <users>\r\n 
<user>\r\n <firstname>

This is not the full xml, but as you can see I have \r\n slashes all over my 
output xml. can I send my xml to web service like this. 

Thanks.

-- 
vinki
0
nitugupta2 (12)
8/8/2006 11:26:01 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
784 Views

Similar Articles

[PageSpeed] 32

Hey,

The '\r\n' are the symbols for new line, as you are finally packing with 
XMLTextWriter class, these doesn't effect your file. Hence you can pass the 
file to webservice, will not be a problem

To calrify you in details, better save that stream to a file on to the disk 
and try to open it from IE. What do you see ?


-- 
Every thing is perfect, as long as you share!!!


"vinki" wrote:

> Hi Everyone,
> 
> I am constructing an xml file, but when I try to read it there are some 
> extra slashes in the output. Can anoyone tell me why there are some extra 
> slashed and can i send the file to web service with those extra slashes. 
> below I am constructing the document
> 
> 
> StringWriter sWriter;
> SqlDataReader dr;
> 
> dr = SqlHelper.ExecuteReader(connectionString,"SP_UsersData_Get");
> XmlTextWriter w;
> sWriter = new StringWriter();
> //w = new XmlTextWriter("C:/text.txt", System.Text.Encoding.UTF8);
> w= new XmlTextWriter(sWriter);
> 
> w.Formatting=Formatting.Indented;
> w.Indentationfiltered=2;
> w.WriteStartDocument(true);
> w.WriteStartElement("test");
> w.WriteStartElement("system");
> w.WriteAttributeString("id", "UML");
> w.WriteElementString("version", "1.0");
> w.WriteStartElement("configuration");
> w.WriteElementString("update_password","True");
> w.WriteEndElement();
> w.WriteStartElement("users"); 
> while(dr.Read())
> {
> w.WriteStartElement("user");
> w.WriteElementString("firstname", dr["first_name"].ToString());
> w.WriteElementString("lastname", dr["last_name"].ToString());
> w.WriteElementString("email", dr["email"].ToString());
> w.WriteElementString("loginid", dr["Login"].ToString());
> 
> w.WriteElementString("status", "A");
> w.WriteStartElement("roles");
> w.WriteStartElement("role");
> w.WriteString("Agent");
> w.WriteStartElement("groups");
> w.WriteStartElement("group");
> w.WriteElementString("path", "Services/irvine/" + 
> dr["supervisor"].ToString());
> w.WriteEndElement();
> w.WriteEndElement();
> w.WriteEndElement();
> w.WriteEndElement();
> w.WriteStartElement("relations");
> w.WriteStartElement("relation");
> w.WriteElementString("type", "UML");
> w.WriteElementString("externalid", dr["Login"].ToString());
> w.WriteEndElement();
> w.WriteEndElement();
> w.WriteEndElement();
> }
> w.WriteEndElement();
> w.WriteEndDocument();
> w.Close();
> 
> 
> }
> 
> When I do sWriter.ToString , It gives me an output file like below:
> "<?xml versionfiltered=\"1.0\" encoding=\"utf-16\" 
> standalone=\"yes\"?>\r\n<a>\r\n <system id=\"UMA\">\r\n 
> <version>1.0</version>\r\n <configuration>\r\n 
> <update_password>True</update_password>\r\n </configuration>\r\n <users>\r\n 
> <user>\r\n <firstname>
> 
> This is not the full xml, but as you can see I have \r\n slashes all over my 
> output xml. can I send my xml to web service like this. 
> 
> Thanks.
> 
> -- 
> vinki
0
dskcheck (22)
8/9/2006 7:54:01 AM
Reply:

Similar Artilces:

Convert datatype using query
I have create a query which combines two tables; ASSETS and UNITINFO. The UNITINFO table is linked from another database and the ASSETS table has a field that looks up a field called UNIT # from the UNITINFO table. Both fields are called UNIT # but the datatype on the UNITINFO table is set to Text and the UNIT # field on the ASSETS table is set to Number since it is a lookup field. I cannot change the datatype on the UNITINFO table to Number as the field contains both numbers and text. So when I ran my query that I created to pull data from both tables it gave me an error bec...

XML Desialization of array list
Here's a simple example (VB.NET): Option Strict What would the code look like to deserialize this example? Imports System Imports System.Collections Imports System.IO Imports System.Xml.Serialization Public Class App1 Shared Sub Main() Dim list As ArrayList = New ArrayList() Dim out As StreamWriter = New StreamWriter("array.xml") Dim ser As XmlSerializer = New XMLSerializer(list.GetType()) list.Add("a") list.Add("2") list.Add("three") ser.Serialize(out, list) End Sub End Class Peter,...

Convert Access97 to 2000
Hello, we're currently running access97 and would like to convert it to 2000, but we don't know what is the administrator password for this database. Also this database is running on multi user and have difference permission for diffence users. Could someone help me how to do make this happen but keep the currently permission retaint. Thanks ...

Convert Word 6.0 to Word 2003 programatically
With the latest security update from MS Security Existing word templates documents could not be loaded and they started throwing exceptions each time we load. We would like to convert the existing Word 6.0 to Word 2003 programmatically or by using a tool. How do we convert using .NET? Or any existing MS Tool Thanks for the help It sounds like your problem maybe with the KB973904 security update. Try removing it. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, ...

CImage::AlphaBlend and converting to 32-bit bitmap
Hi, I'm using the CImage::AlphaBlend function in my program. This works well, but only if the bitmap attached to the CImage object is already in 32 bit format. Otherwise AlphaBlend does nothing. I'm having a hard time figuring out how to convert other bitmap formats to 32 bit. Alternatively, is there a way to access the bitmap directly? There is the CImage::GetBits function. How do you use the array that's returned to manipulate the bitmap? (How do you treat different bitmap formats?) Any suggestions would be greatly appreciated! Lena ...

How do I specific digits in a long string?
I have a column with a long number, similar to a VIN number on a car. I need to be able to display only the 3rd and 4th digits, which represent the year. Example: 3692040105 (year is 1992) 3694789321 (year is 1994) 3795564113 (year is 1995) I want this column to look like- 92 94 95 Is this possible? Is there a formula or a custom formating I can use? =mid(a1,3,2) will pick out those 2 characters "PhilGTI" wrote: > I have a column with a long number, similar to a VIN number on a car. > I need to be able to display only the 3rd and 4th digits, which represent > ...

Variable Length String
hi, i have the following code: Dim Msg As String Msg = Msg & "Award Title:" & Cells(r, 9) & vbCrLf now when i run the marcro, i get the following error: Run-time error '5': Invalid procedure call or argument but when i shorten the title from from 50 characters to about 15 characters it works fine. is there a limit on how many characters a string can have, if not why am i getting this error? any assistance is greatly appreciated, thanks in advance. ~q From xl2002's help (I hit F1 with the cursor on "String" in the dim statement): Ther...

XML/XSL #2
Hi everyone, I am performing an XSL transformation on IIS 5 with a dot net application and I am getting the following error message: This is an unexpected token. The expected token is 'WHITESPACE'. Line 2, position 62. Error Dump: System.Xml.XmlException: This is an unexpected token. The expected token is 'WHITESPACE'. Line 2, position 62. at System.Xml.Schema.DtdParser.SkipWhitespace(Boolean fRequired) at System.Xml.Schema.DtdParser.ParseExternalID() at System.Xml.Schema.DtdParser.ParseDocTypeDecl() at System.Xml.Schema.DtdParser.Parse() at System.Xml.XmlTextReader....

XML file loaded and stored as cached dataset?
Have loaded balanced web servers that we do not allow to connect to our database. Content is created and pushed to these sites. I want to add a web service that may get multiple requests a second depending on peak access. I have built an XML file from SQL DB and pushed this file to web server. I want to load XML file at application startup and leave it cached if possible (it will vary in size from 1-2MB) and treat it like an SQL table (rows & columns) that I can filter on and send XML subset back to caller. Maybe I should keep XML document loaded as XML Doc and pull my nodes/da...

Converting a column of information into a row of information
I was curious if anyone knew of a way to convert a column into a row Essentially we receive a spreadsheet a few times a month that has a fe columns of information. Our database however can only accept cs uploads and they have to follow a very strict template. In order t properly upload the data that we are receiving I would need to turn columns into rows (or optimally into a single cell with each piece o data from that column separated by a comma). Our template works as follows. We have rows for contact name, address phone number, ect... At the end of the spreadsheet there are 3 column in w...

Re: converting a publisher booklet to pdf
You need to change the publication to single pages rather than a booklet. Change to one page per sheet. -- Mary Sauer http://msauer.mvps.org/ "Holly Eaton" <idonthavefakeemail@huh.com> wrote in message news:... > Message-ID: <807ef77855094ed897dc2635e288e6d2@newspe.com> > X-Mailer: http://www.umailcampaign.com, ip log:72.16.241.123 > Newsgroups: microsoft.public.publisher > NNTP-Posting-Host: 22.bb.5446.static.theplanet.com 70.84.187.34 > Path: TK2MSFTNGP01.phx.gbl!TK2MSFTNGP05.phx.gbl!newspe.com > Lines: 1 > Xref: TK2MSFTNGP01.phx.gbl microsoft.p...

converting PDF to Excel Sheet?
Hello, I would like to convert a PDF to Excel using a simple linux command line tool. Anyone know if that is possible? The tool coul also be a windows tool, but I am looking for a tool that is completel automated, with no user intevention. The reason is that I have a program that downloads PDFs every hour o so, and I would like to convert that pdf to an excel sheet so i coul grab data off it easily. Or maybe, does anyone know of an easier way to grab tables informatio off PDFS? thank -- Message posted from http://www.ExcelForum.com Take a look at PDF and Excel http://www.mvps...

how to sort a string?
Hi Group Trying to sort a string looking like: bv-8,ok-3,bv-5,sk-1,bh-2,ok-9 etc into: bh-2,bv-5,bv-8,ok-3,ok-9,sk-1 etc Grateful for some help. Brgds CG Rosen Try This code. Sub SortData() InputStr = "bv-8,ok-3,bv-5,sk-1,bh-2,ok-9" 'put data into an array SortArray = Split(InputStr, ",") For I = LBound(SortArray) To (UBound(SortArray) - 1) For J = (I + 1) To UBound(SortArray) If SortArray(I) > SortArray(J) Then temp = SortArray(I) SortArray(I) = SortArray(J) SortArray(J) = temp End If Next J Next I OutputStr = Join(Sort...

Convert
Is it possible to convert a Money file created in the USA version to that of the UK version? Thanks in advance The general way is QIF Export then Import. It's involved and has limitations like loan accounts don't QIF. See http://www.bollar.org/msmoney/#Q1. "Crispy" <nowayspammers@hotmail.com> wrote in message news:uQKSfzfyDHA.2500@TK2MSFTNGP09.phx.gbl... > Is it possible to convert a Money file created in the USA version to that of > the UK version? ...

access 2000 converting text to number format
a database in my office was created and the person who designed it put every field in a table as a text field. the numbers that are in those fields need to be change to a number to related to other tables. is there VB code or script to change it? or any other waY? Can you change the data type of the field to be Number? ...

Converting Access to MS SQL
I got a big Access file (1 400 tables) to convert to SQL and I would > like to be provided with some automated tools, except upsizing wizard > and DTS, to convert it on my own. > > I got a lot of forms and query to convert too. > > I analysed a tool suggested by Douglas last week, but it convert only the data, and not the froms and query. Can someday provide me with other tool name ? > > Thanks, > > Guy As I told you before, SQL Server doesn't have forms and queries in it: it's a database only. Therefore it's impossible to find a product that will co...

Converting from Windows Mail to Outlook 2007
I just converted from Mail to Outlook. My inbox came over during conversion but not any of the Mail personal folders (winmail.fol) or any of the e-mail messages in these folders. I tried to import them but Mail doesn't file them as .pst folders. Is there a way to get these folders and the email in them into Outlook? As I understand it you Export msgs from Mail to Outlook "Steven" <Steven@discussions.microsoft.com> wrote in message news:964C90B9-3AFC-4667-97D0-13047CCD116D@microsoft.com... >I just converted from Mail to Outlook. My inbox came over during >c...

Converting Money 98 files to 2005
I've seen the question asked but haven't seen a response. I'm trying to load Money 98 backup files into Money 2005 (moving to new machine). It doesn't matter whether I use Open or Restore or Repair. I get an incompatible version message. What can I do to convert the 98 backups into something 2005 can read? See http://umpmfaq.info/faqdb.php?q=1. "Manne" <Manne@discussions.microsoft.com> wrote in message news:ED4C824F-94DD-488E-A9B5-F5E16FE42F94@microsoft.com... > I've seen the question asked but haven't seen a response. I'm trying to loa...

Convert outlook data to MailDir
Hello, I'm migrating from Outlook to Websquirrel and therefore I have to convert all my current emails to the "MailDir" format. Does anybody know where I can find tools and how I would this?? Is this possible at all? Fritz Fritz Bayer <fritz-bayer@web.de> wrote: > I'm migrating from Outlook to Websquirrel and therefore I have to > convert all my current emails to the "MailDir" format. If there are any tools for this, Google should be able to find them for you. -- Brian Tillman ...

Convert to 97 Access Database
Hi Everyone, Have a quick question, I'm using MS Access 2007, not fully up to speed with it yet. In Access 2003 - you had an option to convert a database to a 97 Access DB >>Tools >>>>Convert Database >>>>>>Convert to 97 Access Database But I am unable to find this option in Access 2007? Any help, much appreciated Thanks Paul The option wasn't included in Access 2007. Remember that Access 97 is ten years older than Access 2007: is it realistic to expect a product to work with a 10 years old of the same product? -- Doug Steele, Microsoft ...

serialization of XML objects....
Can I serialize an System.Xml.XmlNode object or is better to use the 'InnerText' method to extract the node defintion? Cheers in Advance Jim Jim wrote: > Can I serialize an System.Xml.XmlNode object or is better to use the > 'InnerText' method to extract the node defintion? You can use OuterXml property or use WriteNode() method or XmlTextWriter class. -- Oleg Tkachenko http://www.tkachenko.com/blog Multiconn Technologies, Israel ...

How can I convert hours worked to a number to multiply an hourly r
I have a spreadsheet to enter my employees hours. I have to convert the minutes into a number to multiply by the hourly rate. Currently I have a column with the hours the one with the minutes and a one to recalculate the minutes. Example A1=37 hours A2=17 minutes A3=A2/60 A4=A1+A3 A4 is linked to another spreadsheet that multiplies this by the hourly rate. About 7 out of 10 are usually correct but the other three may be off by 2 to 6 cents. Is there another way to set this up to be accurate? I have tried to extend the number to many decimal points and made sure the cell...

Updating referential integrity and XML
I am trying to use XML to update customer information in our SQL server database. The customer data has some referential integrity. A simple example would be two tables, employee and department -- each employee may belong to a department, where emp.dep_id = dep.id (in other words, emp.dep_id is a foreign key to dep.id). The problem is the customer (who is supplying the updates) has no idea about the foreign key. The XML they provide can (or will have to!) include the FK reference (as I have added this relationship to my .xsd. But the values in the incoming XML will more than likely *...

My WMP library contains wav files best way to convert to mp3
I'm loading my Vinyl albums into WMP as WAV files. I've completed 100 and now have a very large file (48G). How can I convert the WAV files to MP3 without having to recreate my WMP library. i've split all the tracks and renamed them and added art work. I've converted the wav files to MP3 but when I drag the converted files into my WPM library I get a red X next to track that is associated with that file. If I do nothing will WMP automatically convert the files when I sync a device to the WMP? WMP supports transcoding When syncing, the files will be translate...

String to Number Conversion Problem
Hi, I'm running a german Office, which means Decimal-Seperator is "," and Thousands-Seperator is "." and I want to convert Strings which are using "." and "," as Decimal- and Thousands-Separator to Numbers. For example I want to convert "25.000" to 25. I've tried Application.UseSystemSeparators = False Application.DecimalSeparator = "." Application.ThousandsSeparator = "," vDouble = CDbl("25.000") Application.DecimalSeparator = "," Application.ThousandsSeparat...