473,605 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlDocument.Doc umentElement is null?

The DocumentElement is always null? and is readonly?

How to I add node items to the root?

I'm try to create a document from nothing.
All the samples start by loading a string or file.

Thanks,

Schneider
Nov 12 '05 #1
3 14346
The XML version of Hello World!
XmlDocument doc = new XmlDocument();
doc.AppendChild (doc.CreateProc essingInstructi on("xml", "version=\"1.0\ "
encoding=\"UTF-8\""));
XmlElement root = doc.CreateEleme nt("root");
doc.AppendChild (root);
root.InnerText = "Hello world!";
Console.WriteLi ne(doc.OuterXml );
Console.Read();
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"schneider" <00**@0000.SPAM > wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
The DocumentElement is always null? and is readonly?

How to I add node items to the root?

I'm try to create a document from nothing.
All the samples start by loading a string or file.

Thanks,

Schneider

Nov 12 '05 #2
Thanks,

Never created a doc via code and Xml object model before...

I think I need a good ref book? VB?

From Xsl,Xml,Paths,. .. there seems to be a lot of functionality.

Schneider
"Dennis Myrén" <de****@oslokb. no> wrote in message
news:Ae******** ********@news2. e.nsc.no...
The XML version of Hello World!
XmlDocument doc = new XmlDocument();
doc.AppendChild (doc.CreateProc essingInstructi on("xml", "version=\"1.0\ "
encoding=\"UTF-8\""));
XmlElement root = doc.CreateEleme nt("root");
doc.AppendChild (root);
root.InnerText = "Hello world!";
Console.WriteLi ne(doc.OuterXml );
Console.Read();
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"schneider" <00**@0000.SPAM > wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
The DocumentElement is always null? and is readonly?

How to I add node items to the root?

I'm try to create a document from nothing.
All the samples start by loading a string or file.

Thanks,

Schneider


Nov 12 '05 #3
Just continue laborating with the XML DOM and you will be up and running in
a short time.

The best book IMO is google, if you get stuck try a google search on the
keywords of your problem(like "C# XML SelectSingleNod e"), and you are very
likely to find something useful on the topic.
There are also a number of sites on the net dedicated to XML.
www.xmlforasp.net
is just one of them.

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"schneider" <00**@0000.SPAM > wrote in message
news:ux******** ******@TK2MSFTN GP15.phx.gbl...
Thanks,

Never created a doc via code and Xml object model before...

I think I need a good ref book? VB?

From Xsl,Xml,Paths,. .. there seems to be a lot of functionality.

Schneider
"Dennis Myrén" <de****@oslokb. no> wrote in message
news:Ae******** ********@news2. e.nsc.no...
The XML version of Hello World!
XmlDocument doc = new XmlDocument();
doc.AppendChild (doc.CreateProc essingInstructi on("xml",
"version=\"1.0\ "
encoding=\"UTF-8\""));
XmlElement root = doc.CreateEleme nt("root");
doc.AppendChild (root);
root.InnerText = "Hello world!";
Console.WriteLi ne(doc.OuterXml );
Console.Read();
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"schneider" <00**@0000.SPAM > wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
> The DocumentElement is always null? and is readonly?
>
> How to I add node items to the root?
>
> I'm try to create a document from nothing.
> All the samples start by loading a string or file.
>
> Thanks,
>
> Schneider
>
>



Nov 12 '05 #4

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

Similar topics

6
7348
by: Yechezkal Gutfreund | last post by:
I have been using the following code (successfully) to read Xml formated text packets from a TCP stream. The output from the server stream consists of a sequence of well formed Xml documents written to the output stream. We are willing to pay $ to any expert (e.g. MVP) consultant who has to time to help us track down this problem. (we will discuss rates if you can prove your expertise, and problem solving approach).
4
4835
by: Robert Rossney | last post by:
I'm trying to send and receive XmlDocument objects using the System.Messaging.dll functions. The code I've written follows, as best I can tell, the methodology used in the sample code for the XmlMessageFormatter class. But it isn't working -- specifically, receiving isn't working. What am I doing wrong here? I begin by creating a MessageQueue object and setting up its XmlMessageFormatter to handle XmlDocument objects: System.Type...
2
6199
by: Dave | last post by:
Hi, Is there an easier way to pull a subset of nodes from one XmlDocument to another? I have the code below but would like to know if there is a more streamlined method. Thanks, Dave XmlNodeList nodeList = doc1.SelectNodes("//row"); foreach (XmlNode nodeCode in nodeList) { sb.Append(nodeCode.OuterXml);
3
10961
by: TnaG | last post by:
Can someone answer this probably obvious question. I have an xmldocument that i want to apply an xslt file to. All the examples i find assume u are applying the xslt to an xml file you've read in. How can i apply the xslt to an XmlDocument i've just built? This is wrecking my head, so any code sampe would be greatly appreciated !
4
15977
by: aaa | last post by:
Can someone show me a snippet that creates a very simple XML doc with either a root and chilc nodes or root child nodes, and attributes. I have looked all around and every example I try I get an error of either: 1. Cannot set a value on node type: Element. 2. Specified argument was out of the range of valid values. 3. This document already has a DocumentElement node. Here is the code i've been working with:
3
1859
by: Mungo Jerrie | last post by:
Hi there :-) I have some problems with the same instance of my xmldocument across 3 different classes. See code below: class one { protected static XmlDocument doc = new XmlDocument(); public static XmlDocument getXmlDocument(){
1
3225
by: David Dvali | last post by:
How can I check if the XmlDocument contains some element? For example: <root> <elem1> <optional> Some data <optional> </elem1> </root> How can I check if the XmlDocument contains "optional" element?
0
1260
by: Mae Lim | last post by:
Dear all, I'm newbie to XML in C#. Below it's the existing XMLDocument I need to generate using System.Xml. The <CustData> will loop thru a recordset to generate it. Example Codes :- XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0","utf-8",null);
5
6184
by: Gustaf | last post by:
I've been trying to update my code to the new XslCompiledTransform class without success. The following method takes an XML and XSL file, and returns an XmlDocument object. Can anyone figure out how to write the parameters to the XslCompiledTransform.Transform() method in this case? static XmlDocument Transform(string xml, string xsl) { try { XmlDocument xmlDocIn = new XmlDocument();
0
8004
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
7934
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
8288
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...
0
6743
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
5886
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
5445
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
3958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1271
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.