473,473 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Creating DOM Document from Sratch

Hello!

I', trying to create DOM based XML document. First I create XmlDocument
object and then read other XML DOM Document and modifie the first one.
I'm putting Noden and Attributes tto the first XML DOM document when needed.
Everything seems to be allrigth but when I trying to save the scratch based
DOM Document wirj following code I get an error: "Cannot use a prefix with
an empty namespace".

FileStream fs = new FileStream(dumpFile, FileMode.OpenOrCreate,
FileAccess.Write);

XmlTextWriter w = new XmlTextWriter(fs, Encoding.UTF8);

w.Formatting = Formatting.Indented;

document.Save(w);

w.Flush();

w.Close();

What is wrong adn what this "Cannot use a prefix with an empty namespace"
errormessage measn? Is it not allowed to create in C# a XML DOM document
without usig Load method first.

Cheers!
Jan 29 '06 #1
1 2699


JackieWilson wrote:

I', trying to create DOM based XML document. First I create XmlDocument
object and then read other XML DOM Document and modifie the first one.
I'm putting Noden and Attributes tto the first XML DOM document when needed.
Everything seems to be allrigth but when I trying to save the scratch based
DOM Document wirj following code I get an error: "Cannot use a prefix with
an empty namespace".


We need to see what you are trying to create with the DOM then, it
sounds as if you are using namespaces or prefixes in qualified names
incorrectly.
Try to reduce your code to the minimum that causes the error then show
us the code.
Make sure if you want to create XML with namespaces, e.g. elements in a
namespace that you use namespace aware overloads of CreateElement e.g.
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlDocumentClassCreateElementTopic3. asp>
allows you to pass in the prefix, local name and the namespace URI
XmlElement element =
someDocument.CreateElement("html", "p",
"http://www.w3.org/1999/xhtml");
There are also namespace aware overloads of CreateAttribute
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlDocumentClassCreateAttributeTopic 3.asp>
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 29 '06 #2

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

Similar topics

6
by: Kerri McDonald | last post by:
We have an application where the user fills out many screens and when they are done, we are supposed to display the text they entered in a word or excel format. That is fairly easily accomplished...
20
by: svend | last post by:
I'm messing with some code here... Lets say I have this array: a1 = ; And I apply slice(0) on it, to create a copy: a2 = a1.slice(0); But this isn't a true copy. If I go a1 = 42, and then...
7
by: Russ | last post by:
Hi All, I have a problem getting the following simple example of "document.write" creating a script on the fly to work in all html browsers. It works in I.E., Firefox, and Netscape 7 above. It...
2
by: pshvarts | last post by:
(I'm new in SOAP) I get some wsdl file (from apache service ). I tried creating SOAP client with .NET - trying to add Web Reference and get error like: "Custom tool error: Unable to import...
6
by: Adam Tilghman | last post by:
Hi all, I have found that IE doesn't seem to respect the <SELECT> "multiple" attribute when set using DOM methods, although the attribute/property seems to exist and is updated properly. Those...
5
by: sam | last post by:
Hi all, I am dynamically creating a table rows and inerting radio buttons which are also dynamically created. Everything works fine in Firefox as expected. But I am not able to select radio...
3
by: patrickkellogg | last post by:
I have this code when you click the buttom is suppose to add a job history. it works with firefox, opera, but not ie. (please note - new entries don't have all the elements in them yet, but...
1
by: skyson2ye | last post by:
Hi, guys: I have written a piece of code which utilizes Javascript in PHP to create a three level dynamic list box(Country, States/Province, Market). However, I have encountered a strange problem,...
0
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,...
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...
1
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...
0
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...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.