473,691 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
+ 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(dump File, FileMode.OpenOr Create,
FileAccess.Writ e);

XmlTextWriter w = new XmlTextWriter(f s, Encoding.UTF8);

w.Formatting = Formatting.Inde nted;

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 2715


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/frlrfSystemXmlX mlDocumentClass CreateElementTo pic3.asp>
allows you to pass in the prefix, local name and the namespace URI
XmlElement element =
someDocument.Cr eateElement("ht ml", "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/frlrfSystemXmlX mlDocumentClass CreateAttribute Topic3.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
8022
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 by changing the content type in the response object. On one of the screens where they enter data, they also have the ability to upload a word document containing additional information. This is also not a problem, and is working fine. Now they...
20
3108
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 alert(a2) I will see 42 there too. I'm doubting, but I was
7
2150
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 doesn't seem to work in Netscape 4. Am I missing something with it? When I look at page source in Netscape 4 the script isn't even shown. Can Netscape 4 create scripts on the fly at all?
2
4192
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 WebService/Schema. Unable to import binding..." I thought may be wsdl file is not good enough (it was created with qsoap toolkit), so I paste-copy sample from http://www.w3.org/TR/2001/NOTE-wsdl-20010315#_wsdl (will paste below) and receive same error...
6
7254
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 changes just don't make it onto the screen. Am I doing something wrong here? If not, is there a better feature test I can use than "appName.match()"?
5
12545
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 buttons in IE. It does not even throw any errors. I have searched over the net but could not find anyhelp. Hope some experts here could help me. Here is part my code that dynamically generates the radio buttons, I cannot paste the entire code as it is...
3
1923
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 enough to get the idea). Here is the code: ----------------------------------------------------------------- <html>
1
3751
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, and I have spent three days trying to debug but to no avail. Everything is OK when there are only two dependent list boxes, but when adding the third child list box, a problem appears: if I populate the third box only with the value: new...
0
9079
Oralloy
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...
0
8952
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8793
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,...
0
8796
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6457
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 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...
0
5817
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();...
0
4322
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...
1
2968
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
2
2234
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.