473,385 Members | 1,846 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.

XmlDocument.DocumentElement 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 14285
The XML version of Hello World!
XmlDocument doc = new XmlDocument();
doc.AppendChild(doc.CreateProcessingInstruction("x ml", "version=\"1.0\"
encoding=\"UTF-8\""));
XmlElement root = doc.CreateElement("root");
doc.AppendChild(root);
root.InnerText = "Hello world!";
Console.WriteLine(doc.OuterXml);
Console.Read();
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"schneider" <00**@0000.SPAM> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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.CreateProcessingInstruction("x ml", "version=\"1.0\"
encoding=\"UTF-8\""));
XmlElement root = doc.CreateElement("root");
doc.AppendChild(root);
root.InnerText = "Hello world!";
Console.WriteLine(doc.OuterXml);
Console.Read();
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"schneider" <00**@0000.SPAM> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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 SelectSingleNode"), 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**************@TK2MSFTNGP15.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.CreateProcessingInstruction("x ml",
"version=\"1.0\"
encoding=\"UTF-8\""));
XmlElement root = doc.CreateElement("root");
doc.AppendChild(root);
root.InnerText = "Hello world!";
Console.WriteLine(doc.OuterXml);
Console.Read();
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"schneider" <00**@0000.SPAM> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
> 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
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...
4
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...
2
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 ...
3
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...
4
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...
3
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(); ...
1
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"...
0
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 :- ...
5
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.