473,769 Members | 4,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

save an xml document as a string

abehm
35 New Member
Hello,
I am trying to save an entire xml document as a string and then insert it to a sql server db as an xml data type. The problem is when I read the xmldocument to the string, somewhere along the way "\"'s are inserted in front of the attribute values in the xml. Can anyone help me?

Expand|Select|Wrap|Line Numbers
  1.          if (File.Exists(file))
  2.          {
  3.              XmlDocument mydoc = new XmlDocument();
  4.              mydoc.Load(file);
  5.              xmlsrc = mydoc.OuterXml;
  6.              return xmlsrc;
  7.          }
  8.  
sample file before :
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <BusinessData>
  3.   <Test ID="789-1">
  4.     <Analysis Status="Complete" PassFail="False">
  5.       <Element>1</Element>
  6.     </Analysis>
  7.   </Test>
  8. </BusinessData>
sample file after:
Expand|Select|Wrap|Line Numbers
  1. <?xml version=\"1.0\" encoding=\"utf-8\"?>
  2. <BusinessData>
  3.   <Test ID=\"789-1\">
  4.     <Analysis Status=\"Complete\" PassFail=\"False\">
  5.       <Element>1</Element>
  6.     </Analysis>
  7.   </Test>
  8. </BusinessData>
May 31 '07 #1
4 2077
abehm
35 New Member
oh nevermind, i removed the first line of the xml and it now saves to the server.
May 31 '07 #2
dorinbogdan
839 Recognized Expert Contributor
Thanks for sharing the solution.
It may help other memebers.

Peace on you,
Dorin.
Jun 1 '07 #3
somannar
1 New Member
Hi,

I m looking for the same requirement in JAVA will you help me to send the code which may helps me to understand the way it is implemented.

thanks

Somanna R
Jun 4 '07 #4
dorinbogdan
839 Recognized Expert Contributor
Welcome to TheScripts TSDN...

Unfortunately, we cannot provide full source code (it's against site rules), but suggestions and small snippets.
And you are required to try yourself writing the code.
Please post your code and then will see what is wrong.

Thanks,
Dorin.
Jun 4 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3255
by: Francesc Guim Bernat | last post by:
Dear Colleagues, i'm developing a C++ .NET based application that works with System.Xml library. My problem appears when i try to save a document througt XmlDocument->Save method, because it seems to add some strange characters at the beginning of the saved XML document. For instance, if first i print the document throught System::Console class, the output is:
1
2458
by: Francesc Guim Bernat | last post by:
Dear Colleagues, i'm developing a C++ .NET based application that works with System.Xml library. My problem appears when i try to save a document througt XmlDocument->Save method, because it seems to add some strange characters at the beginning of the saved XML document. For instance, if first i print the document throught System::Console
9
4500
by: Marco Krechting | last post by:
Hi All, I have a page with a list of hyperlinks. I want to save information in a cookie about the fact that I entered an hyperlink or not. When I click one of the hyperlinks I want this stored in a cookie and a small bullit shown in front of the hyperlink, so when I reload the page I can immediately see which hyperlinks I already visited that day.
1
5879
by: DraguVaso | last post by:
Hi, I found some examples for storing the FormSettings of a Form in an XML-file, but none of these could match my criteria: What I am looking for is the possibility to save the FormSettings of multiple Instances of 1 form. I have a Form frmSource from which I have multiple Instances, each with a unique Identifier. So when I Load or Close a specific instance, I want to load or save the Settings (Top, Height, Width, etc) in an XML-file....
7
3702
by: joseph.inglis | last post by:
I have a web browser object on a form which I have set to edit mode and use the UCOMIConnectionPointContainer interface to hook in and catch events. All working sweetly. Except there are instances where i rewrite the Document.Content and the
8
3712
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box and save it to a file. This step is not to hard however the contents of the textarea is mostly latex source so it contains just about every special character you can imagine. My question is this, how do I save an exact copy of the textarea...
2
4595
by: csgraham74 | last post by:
Hi, I have a requirement in work that i give a person the ability to create a html document using a richt text editor. What i then want to do is save the HTML doct to my server & insert reference in a database so that i can retrieve the html document. Basically i dont have a clue how to convert a string in HTML format (taken from the RTE) to an actual document and then save it to a folder. Can anyone point me in the correct direction.
0
3752
by: ppardi | last post by:
I'm developing an addin for Word 2007 and I need to determine whether a user saves a Word 2007 document in an older format (97-2003) after a save as is done. The scenario is that the user starts out with a Word 2007 document, saves that document to disk, then saves the same document in an older format If the user saves a doc in an older format, I want to turn off certain features of my add-in. I'm able to trap the save event easily...
1
1768
by: not_a_commie | last post by:
Here are a few thoughts for loading and storing your xml using the XmlDocument class: First, don't ever insert the header manually. This is to be done by the writer. In other words, don't do this: document.AppendChild(document.CreateXmlDeclaration("1.0", "UTF-8", null)); If you do that and then write your document to a stream with an
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9981
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9850
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7396
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3948
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.