473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Output XML non-breaking space (#160) from code


I have an XmlDocument object, and need to output the   entity from
my code. I potentially need to output other similar entities such as
£ for the GBP sign.

Here is some example code:

//-----------------
XmlDocument doc = new XmlDocument();
XmlElement testElement = doc.CreateElement("test");
doc.AppendChild(testElement);

XmlNode spaceNode = doc.CreateEntityReference("160");

testElement.AppendChild(spaceNode);
StringWriter sw = new StringWriter();
XmlWriter xw = new XmlTextWriter(sw);
doc.WriteContentTo(xw);
//-----------------

So far I have tried:

// Produces " "
doc.CreateTextNode(" ");

// Produces " 
doc.CreateTextNode(" ");

// Exception: "Cannot create an EntityReference node with a name
// starting with '#'."
doc.CreateEntityReference("#160");

// Exception: "There is an invalid name character in 160"
doc.CreateEntityReference("160");

It's frustratingly hard just to put " " into my XML document...
Have I missed something obvious?

Thanks,
James.

Jul 21 '05 #1
0 1859

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Yuan HOng | last post by:
In my program I have to call an external program and parse its output. For that I use the os.popen2 function, and then read the output stream. But the complexity is that the external program...
2
by: Tim Meagher | last post by:
I am using the XslTransform class in C#.net to output XML files that include non-ascii Unicode characters such as the Greek capital letter theta U+0398. I can easily outout the data as serialized...
15
by: jackiechan | last post by:
I would like to test some things in C and make a graphical output when running them , something like in java for example http://www.cs.bell-labs.com/cm/cs/pearls/sortanim.html (without buttons...
11
by: Roger Leigh | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The program listed below demonstrates the use of wcsftime() and std::time_put<wchar_t> which is a C++ wrapper around it. (I know this isn't C; but...
26
by: Betaver | last post by:
I just want to output a long long or int64 variable use printf function.But if I use printf("%ld",x); I can't output an x more than long. I can only output it like this: long long a,b,c;...
0
by: Tim Meagher | last post by:
I am using the XslTransform class in C#.net to output XML files that include non-ascii Unicode characters such as the Greek capital letter theta U+0398. I can easily outout the data as serialized...
2
by: Remi.Arntzen | last post by:
I tried to compile a program to a elf shared library for a Linux platform on a windows machine with the command: gcc -o Prog.so -shared -Wl,--oformat -Wl,elf32-i386 however this results in ld:...
21
by: Umesh | last post by:
/*program to search a* in a text file & write output in a file.* indicated any character*/ #include<stdio.h> #include<stdlib.h> int main(void) { FILE *f,*fp; f=fopen("c:/1.txt","r");...
7
by: nas | last post by:
Consider this example program which i hav taken from some site #include <iostream> using namespace std; class Base1 { public: virtual void f() { } };
13
by: Jim Langston | last post by:
I had asked this in comp.lang.c++ with out any answers that would actually work, so I'm hoping someone here may know a way. I am calling C library functions that want to output to stdout. I need...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.