473,770 Members | 6,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create xml node in document with default namespace

Hi,

I would appreciate some help with creating an xml node in a document and
automatically setting the default namespace

The code below loads an xmnldocument with a default namespace --
xmlns=""http://mydomain.org/schema.xsd""

however when i create a nod in it below the node come out with a blank
string set for the "xmlns" attribute.

can anybody suggest how to populate the attribute "xmlns" with
"http://mydomain.org/schema.xsd"
XmlDocument xmldoc = new XmlDocument() ;
xmldoc.LoadXml( @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<root xmlns:xsd=""htt p://www.w3.org/2001/XMLSchema""
xmlns:xsi=""htt p://www.w3.org/2001/XMLSchema-instance""
xmlns=""http://mydomain.org/schema.xsd"">
</root>") ;

XmlNode AddNode;
AddNode = xmldoc.CreateEl ement( "Trial" ) ;

xmldoc.Document Element.AppendC hild( AddNode ) ;

xmldoc.Save( Console.Out ) ;
many thanks in advance

cheers

martin.
Dec 7 '05 #1
0 1030

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

Similar topics

8
3664
by: Daniel Frey | last post by:
Hello, I've got a problem. Either I have missed the most important point or it really does not work: I want to use the document function with an absolut path on WindowsXP Professional and Saxon 8.1. However, retrieving a subnode of the documents content is not possible. Inserting a whole document result set is functional, subset not. Example:
5
2846
by: MoonStorm | last post by:
Hi guys, Please solve a puzzle I am trying to figure out for some time. Let's say I have a fragment stored inside a variable, for instance: <xsl:variable name="layoutSettings"> <module> <size>345</size> <title>whatever</title> </module>
6
8348
by: David B. Bitton | last post by:
I am having a problem deserializing XML when the root node is missing a namespace declaration. My Type has an XmlTypeAttribute with a namespace defined. If I attempt to deserialize the XML, I get the dreaded <elementname xmlns=''> was not expected exception. If I comment out the XmlTypeAttribute, it works just fine. Just so you know, when I instantiate an instance of an XmlSerializer, I pass a default namespace to the ctor. ...
4
20503
by: Krishna Tulasi via .NET 247 | last post by:
Hi, I am having trouble with creation of XML programmatically using .NET. Specifically Im trying to create an element which looks like below and insert into an existing xml doc: <Worksheet ss:Name="TKCSheet1"> </Worksheet> The existing xml doc is: <?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?>
5
17656
by: Paw Pedersen | last post by:
Is it possible to load a XSD and loop throw the nodes and attributes that you whant filled out, and then generate a XML instance with the trees and data that you have filled data in? And how do you do that? Regards Paw
2
2841
by: Oleksandr Brovko | last post by:
Code sample below demonstrates following: We have sample extension object with 2 methods TestMethod - takes XPathNodeIterator as a parameter TestMethod2 - takes string as a parameter also we have CustomXmlResolver, stylesheet takes <XML>SourceDoc</XML> as source XML document also sylesheet retreives <XML>CustomXmlResolverData</XML> XML document through the document function and CustomXmlResolver now we pass $externalDoc/XML node set to...
2
1353
by: WideBoy | last post by:
Hi I have access to a large xml schema namespace which has complicated references, structures, etc for all sorts of things. Amongst which are personDetails, and their UK postal address. What I would like to do is see what sort of instance document I need to create to test it's validity against this complex schema. The xml schema does not have a root node/element, perhaps this is because it is purely a namespace? - I don't know.
10
8815
by: Simon Brooke | last post by:
The DOM API has included public Node importNode(Node,boolean) as a method of the Document interface for a long time. Does anything actually implement it? Xerces 2 is giving me: org.w3c.dom.DOMException: NOT_SUPPORTED_ERR: The implementation does not support the requested type of object or operation. at org.apache.xerces.dom.CoreDocumentImpl.importNode(Unknown Source) at org.apache.xerces.dom.CoreDocumentImpl.importNode(Unknown Source)
4
8283
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my problems and this one is really getting to me... I have a page that allows you to Browse Authors. There are three drop down boxes that auto-populate via AJAX. I have a file which it calls and returns the dynamically built XML file in the boxes...
0
9592
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, 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...
0
9425
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,...
0
10230
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
10058
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...
0
8886
agi2029
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...
1
7416
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
5313
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
3972
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
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.