when I run the following code the leading spaces of the "data" node
are removed. How do I retain whitespace?
private void CreateBasicXmlD ocument()
{
XmlWriterSettin gs writeSettings = new XmlWriterSettin gs();
writeSettings.I ndent = true;
XmlWriter writer = XmlWriter.Creat e( filePath, writeSettings );
writer.WriteSta rtElement("data ");
writer.WriteWhi tespace(" ");
writer.WriteVal ue(" data with leading space");
writer.WriteEnd Element();
writer.Close();
} 4 6047
Steve,
I think you need to set the XmlSpace attribute of the XmlWriter to
XmlSpace.Preser ve.
--BJ
"Steve Richter" wrote:
when I run the following code the leading spaces of the "data" node
are removed. How do I retain whitespace?
private void CreateBasicXmlD ocument()
{
XmlWriterSettin gs writeSettings = new XmlWriterSettin gs();
writeSettings.I ndent = true;
XmlWriter writer = XmlWriter.Creat e( filePath, writeSettings );
writer.WriteSta rtElement("data ");
writer.WriteWhi tespace(" ");
writer.WriteVal ue(" data with leading space");
writer.WriteEnd Element();
writer.Close();
}
On Feb 19, 12:36 pm, BJ Safdie <MSDNNospam...@ nospam.nospamwr ote:
Steve,
I think you need to set the XmlSpace attribute of the XmlWriter to
XmlSpace.Preser ve.
I tried that. the XmlSpace attribute is read only. very confusing!
-Steve
>
--BJ
"Steve Richter" wrote:
when I run the following code the leading spaces of the "data" node
are removed. How do I retain whitespace?
private void CreateBasicXmlD ocument()
{
XmlWriterSettin gs writeSettings = new XmlWriterSettin gs();
writeSettings.I ndent = true;
XmlWriter writer = XmlWriter.Creat e( filePath, writeSettings );
writer.WriteSta rtElement("data ");
writer.WriteWhi tespace(" ");
writer.WriteVal ue(" data with leading space");
writer.WriteEnd Element();
writer.Close();
}- Hide quoted text -
- Show quoted text -
Hi Steve,
The white spaces you add are there. Your code appends a single space character in front of the value.
If you are missing the indentation, bear in mind that WriteWhiteSpace isonly used when manually formatting the xml, which means effectively overriding the indentation. Furthermore, indentation won't happen on the innermost node, and since you only have a single node it won't be broken on two lines. The code below is probably more what you seek.
writer.WriteSta rtElement("data ");
writer.WriteSta rtElement("inne rdata");
writer.WriteVal ue(" data with leading space");
writer.WriteEnd Element();
writer.WriteEnd Element();
On Mon, 19 Feb 2007 18:10:35 +0100, Steve Richter <St************ @gmail.comwrote :
when I run the following code the leading spaces of the "data" node
are removed. How do I retain whitespace?
private void CreateBasicXmlD ocument()
{
XmlWriterSettin gs writeSettings = new XmlWriterSettin gs();
writeSettings.I ndent = true;
XmlWriter writer = XmlWriter.Creat e( filePath, writeSettings );
writer.WriteSta rtElement("data ");
writer.WriteWhi tespace(" ");
writer.WriteVal ue(" data with leading space");
writer.WriteEnd Element();
writer.Close();
}
--
Happy coding!
Morten Wennevik [C# MVP]
On Feb 19, 1:01 pm, "Morten Wennevik [C# MVP]"
<MortenWenne... @hotmail.comwro te:
Hi Steve,
The white spaces you add are there. Your code appends a single space character in front
of the value.
your right! <smacks head I was displaying the xml document thru
Windows Explorer -Internet Explorer. Whatever font it was in really
shrunk down the whitespace.
thanks,
-Steve This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: JayC |
last post by:
Hey guys,
I've noticed that if you have an XML snippet structured like this (I'm
using square brackets instead in case it messes up and HTML readers):
Blah
Blah 2
|
by: John |
last post by:
I have been trying with no result, to force Xerces parsers to ignore
whitespace in my XML file. I have tried several of the NG suggested
setFeature() methods in DOMParser to no avail.
I have now started to use the newest version of Xerces and as a result
I stopped using DOMParser. The following fragment of my code shows how
I create the parser and parse my XML file, which still has <null>
#text fields for whitespace. How can I force...
|
by: Celedor |
last post by:
If I understand correctly, canonicalized XML is a simplified, or
rather, "standardized" form of XML. It is in such a form such that
two documents that are written in different ways, but contain the same
information, will normalize towards one form. This standard form can
then be used as the basis for encryption or digital verification (such
as XML Digital Signature).
If this is the case, then why is whitespace outside of any tags still...
|
by: Wired Earp |
last post by:
I've had some luck using string values "\t" "\n" and "\r" to insert tabs,
newlines and carriagereturn textnodes into a document, but I can't *read*
these nodes, at least not by analyzing the nodeValue. Am i missing
something?
/**
* NodeFilter supposed to remove ignorable whitespace
*/
private class WhiteSpaceFilter implements NodeFilter {
|
by: Tjerk Wolterink |
last post by:
Hello all,
how does xsl handle white space?
I know you can set domething like this
for nice indentation:
<xsl:output method="xhtml" indent="yes"/>
But know i have xsl code like this:
| |
by: Carlitos |
last post by:
Hi there,
A class in Xerces J-API (Java) called TextImpl contains a property that
returns whether the text is ignorable whitespace
(http://xml.apache.org/xerces-j/apiDocs/org/apache/xerces/dom/TextImpl.html#isIgnorableWhitespace()).
I guess when they refer to "ignorable whitespace" in Java we may interpret
that as an "insignificant whitespace" in .NET. Am I correct to say that?
So, I need to manually convert some Java code to C#,...
|
by: amattie |
last post by:
Does anyone have any idea on how I can strip the extra whitespace in
the XML that shows up when I receive a response from an ASP.NET 2.0
webservice? This has been discussed before, but no one has ever come up
with a good answer to what seems like such a common question.
...
|
by: Steve Richter |
last post by:
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 );
|
by: martymix |
last post by:
simple question:
I have a simple <dt>test text</dt>
I get the innerHTML of that dt, and I try and append some text to it
like so:
dt = document.getElementsByTagName('dt')
var text = dt.innerHTML + 'new'
in Firefox, I get "test textnew"
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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
| |