Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spaces in fields using XMLTextWriter

Status
Not open for further replies.

Technocratic

Programmer
Jun 2, 2000
16
US
I am writing an XML file by parsing apart a text file... there are instances when there are spaces at the start or end of some of the fields, and I need to be able to see those for validation purposes.

So if an Incident number is in the text file as " CA00456" I need to have those leading blanks in the XML file, however when I use:

Code:
XMLTextWriter4.WriteElementString(NodeName, CurrentField)

it automatically trims it so I end up with "CA00456"

Is there a way to preserve those spaces in the XML?

I know there is a WriteWhitespace method, but it seems that I might end up having to test each field for spaces as I'm writing, and write the appropriate number of spaces before or after the field... and I'm hoping for a simple property or something that will just tell it to keep the spaces! :)

Any input much appreciated!
 
Use a CDATA section to preserve whitespace -- use the WriteCData() method.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top