retaining leading whitespace in text of an xml node

when I run the following code the leading spaces of the "data" node
are removed. How do I retain whitespace?


    private void CreateBasicXmlDocument()
    {
      XmlWriterSettings writeSettings = new XmlWriterSettings();
      writeSettings.Indent = true;

      XmlWriter writer = XmlWriter.Create( filePath, writeSettings );

      writer.WriteStartElement("data");
      writer.WriteWhitespace(" ");
      writer.WriteValue("     data with leading space");
      writer.WriteEndElement();
      writer.Close();
    }

0
2/19/2007 4:23:38 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
623 Views

Similar Articles

[PageSpeed] 22

* Steve Richter wrote in microsoft.public.dotnet.xml:
>when I run the following code the leading spaces of the "data" node
>are removed. How do I retain whitespace?
>
>    private void CreateBasicXmlDocument()
>    {
>      XmlWriterSettings writeSettings = new XmlWriterSettings();
>      writeSettings.Indent = true;
>
>      XmlWriter writer = XmlWriter.Create( filePath, writeSettings );
>
>      writer.WriteStartElement("data");
>      writer.WriteWhitespace(" ");
>      writer.WriteValue("     data with leading space");
>      writer.WriteEndElement();
>      writer.Close();
>    }

How do you expect the writer to know when your white space is and is not
significant to you? It needs to know because you are asking it to indent
your content, which necessarily implies changes in the amount of white
space. If you turn automatic formatting off, your white space should be
preserved.
-- 
Bj�rn H�hrmann � mailto:bjoern@hoehrmann.de � http://bjoern.hoehrmann.de
Weinh. Str. 22 � Telefon: +49(0)621/4309674 � http://www.bjoernsworld.de
68309 Mannheim � PGP Pub. KeyID: 0xA4357E78 � http://www.websitedev.de/ 
0
bjoern1 (135)
2/21/2007 6:11:40 AM
Reply:

Similar Artilces:

Data Access Page + Text Box + Command Button + Pivot Table
Hello, I'm trying to create a DAP tool that is a simple concept. 1. A user enters a value in the text box 2. User clicks command button 3. Command Button takes TextBox.Value and applies the value as a filter for column 1 in the pivot table. Can someone please help me with code? I have no experience with VBScript, but not too shabby with DAO, ADO, VB & VBA. Thanks players! -- Message posted via http://www.accessmonster.com ...

Display text, Position indicator bar, and color control in Progress bar in VC++6 MFC?
Dear All, I am building a progress bar in VC++6 MFC, how can I dispaly text information on it? Can I control it for only displaying a narrow bar indicator at the position rathern than dispalying a band bar from the begining to the current position? Also, can I easily control its bar and background color? Many thanks, Here is how to do text display on progress control. http://www.codeproject.com/miscctrl/text_progressctrl.asp Here are some custom ones http://www.codeproject.com/miscctrl/ccylinderprogresscontrol.asp Find all kind of examples here http://www.codeproject.com/miscctrl/...

Copy text to a new sheet in Excel
Pete Thanks but will not work . This is what I would like to do Batch No, Varity, 000's, Customer, Sow date, Delivery date, Location, These are headings in a workbook called Batch No's What I want to do is to take the name of a varity (there are 20 differant Varitys) and remove the quantity sown of a named varity of the total stock of that varity at the moment I do it manuly .I can add and subtract the quantitys ok from one book to another but is it possable to let excel do this by every time I enter a certain varity it takes it from stock itself. PLEASE help me ( I am not that ...

Convert a worksheet to a text delimited file
Is it possible to convert workheet to a text delimited with pipes|to seperate the data? If so how can i do this. Thanks Simon "Simon Jelinek" <anonymous@discussions.microsoft.com> wrote in message news:2132901c45aaa$07bb92d0$a301280a@phx.gbl... > Is it possible to convert workheet to a text delimited > with pipes|to seperate the data? > > If so how can i do this. > > Thanks > > Simon You could save it as a comma seperated variable (CSV) file then use an editor like TextPad (http://www.textpad.com/) to convert all the commas to pipes. Stace. C...

XML transform using XSL stored in database
I have an XML document that is transformed using XSL that is stored in a database. It works fine when the XSL is in a file, however when it comes from the database, I only see the text in the XSL (like to column headings) without any formatting. Here is the relevant code: SQLconn.Open(); SqlCommand SQLcmdc = new SqlCommand("SELECT xsl FROM xsl", SQLconn); SqlDataReader dRsltc = SQLcmdc.ExecuteReader(); dRsltc.Read(); string sXml = dRsltc["xsl"].ToString(); SQLconn.Close(); StringReader sr = new StringReader(sXml); xPathDoc = new XPathDocument(sr); xslt.Load(xPathDoc,nul...

how to generate xml schema with UTF-8 instead of UTF-16
Hi, I am writing code with C# to generate xml schema, however, the following code generate a UTF-16 in the first line. This will create some problems. How can get the code/missing what part of the code in C# to generate a first line with UTF-8 instead of UTF-16? Thanks, public XmlSchema CreateSchemaRoot() { schema.ElementFormDefault = XmlSchemaForm.None; schema.AttributeFormDefault = XmlSchemaForm.Unqualified; schema.Version = "1.0"; XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("xsd", schemaNS); schema.Namespaces = ns; return schema; } comic_ra...

What is the quickest way to get an xml based dataset to add entries to SQL Server?
Because there is no 'datareader' involved, what is the most efficient way to get an XML based dataset to be added to an SQL server dataset? I would hate to have to create a new SQL connection and iterate through making "executenonquery" for each row in the dataset. That seems horribly in-efficient. I know of no other way to get an xml based dataset to push data to the database though. Any pointers? Thanks for any pointers, Peter Robbins Freelance Programmer C#/PHP "MurdockSE" <murdock@nc.rr.com> wrote in message news:1153922058.675709.165630@h48g2000cwc.go...

Microsoft Dynamics CRM 2011 Online: Lead Capture
If anyone is interested I just posted a new article on the use the Lead Capture functionality in Microsoft Dynamics CRM 2011 Online. This includes a recorded video as well. http://blog.summitgroupsoftware.com/2010/12/microsoft-dynamics-crm-2011-online-lead-capture/ ...

Manually created button has a BOLD text. How to change?
I have manually added buttons in my CPropertySheet class (to be common for all CPropertyPage that are added to the property sheet). However, the font of the text caption for the buttons is bold for some reason. How can I change it? I tried CFont* pFont = m_btnOK->GetFont(); if (pFont) { LOGFONT lf; pFont->GetLogFont(&lf); lf.lfWeight = FW_NORMAL; pFont->CreateFontIndirect(&lf); m_btnOK->SetFont(pFont); } It doesn't work because pFont is NULL. I call m_btnOK->GetFont() after m_btnOK is created. Please, help. > I call m_btnOK->GetFont() after > m_b...

Excel 2007 to 2008: Headers with color text bad
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I searched the forum, but couldn't find any answers to this... <br><br>I was getting odd text headers in Excel 2008 in some files brought from a Windows machine running Excel 2007. <br><br>The numbers looked familiar and then I recognized they were the HTML code for colors. <br><br>As best I can tell, Excel 2007 for Windows can have colored text in headers and footers, but Excel 2008 for the Mac cannot. When a file with colored text in the header is opened in Excel 2008, t...

Convert XML Schema to Class using XSD
I'm trying convert an XML Schema (http://www.elframework.org/projects/xcri/efc_r1.0.xsd/view) to a VB.Net class using the XSD tool provided with the .NET 2 SDK. However, it's failing to generate the class and is outputting the following error(s); Schema validation warning: Undefined complexType 'http://purl.org/dc/elements/1.1/:SimpleLiteral' is used as a base for complex type extension. Line 433, position 5. Schema validation warning: The derived type and the base type must have the same content type. Line 288, position 3. Schema validation warning: The derived type and...

Help Importing Text File!
Hello, I am new to excel and could really use some help. I have a plain tex file that I would like to import into Excel --but the problem is th text was copied from a webpage and there is no delimited formatting (extra spaces, lines etc.) i.e. I want to create a book database with this info. But the followin was copied like this: Author Name Location Books Writen Publisher I would need to somehow put each line into a column. This is a hug text file formatted like the example above. Could this be done possibl by using a macro? If anyone could help me out (or if you need more info) please ...

I'd like to make text on the screen fade out
Actually I tried to make new window which is applied setWindowRegion. the region was got from BeginPath TextOut EndPath CRgn::RegionFromPath then make window itself fade out on timer event.. Does that make sense? But the region which has text area is not neat.. So, I want to listen your opinion.. How can I make text fade out on screen.. the text should have transparent background.. Does anyone have idea? Depends on what you are fading out *to*. For example, if you are just fading out text on a fixed background, just redrawing the text using differering values of SetTextColor from blac...

Leading zero's
I have 2 fields in access - I need the first to update with 6 digits 000009 , 000546, or 001244 - the send with 3 digits 075, 100, 050 I only want to key in the digits (no zero's) 546 1244 and 75 100 50 how can i get access to add the leading zero's - and the correct number of leading zero's (notice it can be as few as 1 and as many as 5) -- Message posted via http://www.accessmonster.com On Thu, 19 Apr 2007 16:26:39 GMT, "CCTD via AccessMonster.com" <u14229@uwe> wrote: >I have 2 fields in access - I need the first to update with 6 digits 000009 , ...

Proper Text in Userform Text Box
I've built a fairly simple user form with text boxes and combo boxes that inputs values onto a spreadsheet upon closing the userform with a command button Two of the text boxes are for Name and Surname. How can I 'Proper' the text after the user has tabbed on to the next box or closes the user form with the command button? Hi you could use application.proper und the textbox entry -- Regards Frank Kabel Frankfurt, Germany "Anthony Slater" <AnthonySlater@discussions.microsoft.com> schrieb im Newsbeitrag news:201F6E72-A57A-4D2A-9BE0-6A60749C8BD3@microsoft.com.....

Task Wizard XML Viewer
We are in the process of moving mailboxes from an Exchange 2000 box to an Exchange 2003. I downloaded and installed the Exchange SDK to have the capabilities to read the Task Wizard logs. It worked the first to batch runs, but now it doesn't. I can't see the old or the new log files. I got the following error: Line: 45 Char: 7 Error: 'document.frames(...).document.all.OutputArea' is null or not an object Code: 0 Url: file://C:\Documents and Settings\Administrator\Desktop\TaskWizard.hta do you want to continue running scripts on this page? it doesn't matter if I...

can wrap text and merge be used together?
I thought that I was able to use wrap text and merge in a cell together but when I use them together it doesn't wrap. Please let me know if I can use the two controls together. Thank you Yes you can use wrap text and merge in a cell. Highlight the cells you want to merge together Format>cells click on Alignment Tab choose the wrap text and merge cells boxes That should do it although excel usually doesn't adjust the row height to show the wrap so you'll probably have to by dragging on the left or going through Format>Row>height "Elizabeth" wrote: >...

Un-flattening XML-data
Hi, I am exporting data from a MS Access 2003-database and has to transform it into a structured document. The input is as follows: <departments> <department> <name>Community Services</name> <person-in-charge-first-name>Gabriel</person-in-charge-first-name> <person-in-charge-surname>Brown</person-in-charge-surname> <portfolio-councillor-first-name>John</portfolio-councillor-first-name> <portfolio-councillor-surname>Doe</portfolio-councillor-surname> <primary-functio...

Insert text from column A into column B, before text in column B
Hi, I am working with a very large database and I need to find a simple way of inserting the text from 1 column and pasting it into another column, which already has text in it. I want to paste this text to show up before the text in the 2nd column. Here is an example: COLUMN A /images/products/ COLUMN B AA-067.jpg WHAT I WANT TO HAPPEN: COLUMN B /images/products/AA-067.jpg Anyone have any ideas? Please let me know. I've been struggling with what seems to be easy. Thanks :rolleyes: -- dbsupplements ------------------------------------------------------------------------ dbsup...

Text Box Formula
Hi On a user form I have several text boxes - however the first two are relevant to this question. Text Box1 - I enter the date "dd/mm/mm " is it possible for after entering the date that Text Box2 would automatically insert a number e.g. 1 - after filling all the Text boxes and Adding to the Excel Sheet. I would then enter another Date in Text Box1 and Text Box2 would show number 2 - and so on until I've finished with the user form. Any help appreciated Cheers Mully Why bother putting it in a textbox, you just want it for the worksheet, no? Create a Private variable...

circular text?
I know I can use word art to make words in a circle. How can I get a perfect circle with words at a particular font size around it without enlarging the font. If that makes any sense? I have a method on my web page. Scroll way down... http://msauer.mvps.org/wordart_in_microsoft_publisher.htm If you have a draw program it would be a simple operation. Serif has a free program. http://www.freeserifsoftware.com/software/DrawPlus/default.asp -- Mary Sauer http://msauer.mvps.org/ "Bruce Leavitt" <Notthis1@noidea.com> wrote in message news:OqwGS1QcJHA.1676@TK2MSFTNGP03.phx.g...

How can I get Pub 2003 to stop creating text boxes when "pasting"?
I am new to MS Publisher 2003 though I have a lot of experience with Pub 2000. I do a newsletter for a fraternal organization each month and it is all done in Publisher. I get a lot of the articles I publish from members via e-mail. In the past, all I had to do was copy the text from the e-mail and paste it into my publication, change the font and its size and I was done. Today was my first "real" experience with Pub 2003 on a new computer. After I copied an e-mail to put in the newsletter I attempted to 'paste' it. What I got was a lot of extra text boxes. In fact, ...

justifying text both sides
I'm typing a manuscript for someone, and he wants it camera ready. I need to have the text justified both sides. Mostly it works fine, but the last sentance in a paragraph, which frequently only has a few words, ends up justified, too, stretched very oddly across the column. How can I stop this? Do I have to have a separate text frame for that sentance, and justify left that sentance only, with the resultant hassels everytime I change something in a paragraph? Or am I missing something? I have Publisher 2000. Thank you! Laurie Are you using shift+enter at the end of your paragr...

Control source in text box
I am using the following expression in a control source =[ClientDesignator] & "-" & [CatDesignator] & "-" & [FunctionDesignator] & "-" & [Version] When I run the report the data is correct but I would like the version to show up as 0001 instead of 1. Is there a way to do this? Thanks "bobojones" <bobojones69@hotmail.com> wrote in message news:%23Tv4QPjzHHA.4824@TK2MSFTNGP02.phx.gbl... >I am using the following expression in a control source =[ClientDesignator] >& "-" & [CatDesignator] & ...

Xml shredding performance
Hi, we are having some performance issues regarding xml shredding. At this point we are extracting data from xmls from nearly 60 different companies - and therefore 60 different xml structures. The total amount of xml is about 350MB and we are trying to extract the data as fast as possible. Our current system extracts, transforms and loads the data in about five minutes. We would however like to do this in about one minute to be pleased. We use the "nodes/cross apply"-technique to shred the xmls into our internal format. This is how we shred the data. ------...