Latest

Archive

Community news

C++

Communities and Content

Databases

Editorials

Emacs

General

HTML

Java

Notices

PHP

XML

Apache

C++

Database

General

HTML

Java

Javascript

Linux

Object oriented programming

Open source

Perl

PHP

Python

Ruby

SOAP

XML

Suggest a link

Advertise on zez

Contribute

Contact us

About zez


Parsing XML with QT's DOM classes



More about nodes


As I said earlier, there are different kinds of nodes. This simple document shows three different types:

<xml>
  <throckmorton>
    <!-- text describing Mr. Throckmorton -->
    Throckmorton is a really nice guy.
  </throckmorton>
</xml>

"throckmorton" is an element node. The string "text describing Mr. Throckmorton" is a comment node. The string "Throckmorton is a really nice guy." is a text node. Other types of nodes are CDATASection, which is used to escape blocks of text containing characters that would otherwise be regarded as markup, and DocumentFragment, which contains a tree of nodes, and is useful when moving and copying parts of a document.

A node has a node name and, possibly, a node value. In the previous example, the node name of the "xml" node is "xml". Element nodes have no value. Comment nodes always have the node name "#comment", and the node value is the string within the comment ("text describing Mr. Throckmorton", in this case). Similarly, text nodes always have the node name "#text" and the node value is the actual text.

In addition to a name and a value, a node may also have a number of attributes. Consider this xml line:

<img src="images/img42.png" border="0" width="30" height="75" />


In this case, we have an element node named "img", which has four attributes. Attributes also come in name/value pairs. The attribute named "src" has the value "images/img42.png", the attribute named "border" has the value "0" and so on. Attributes can be addressed by name or number.


<< Previous page | 1 | < 2 > | 3 | Next page >> | Printer-friendly page |

Comment List


Topic: Author:
Time:
base64 help sarin n 28.05.2002 09:20

hello sir
i am a student and i have a project module to encode an image file into an xml and decode it and generate
an image file afetr decoding and they have asked me to use jaxp and only using dom not any SAX parser i am
working in java if you have the source code and if you can help me in getting it .it will be a great help can any one help me just mail me at sarin_n21@yahoo.com


XML at start isn't well-formed Mike Moran 28.01.2001 15:03

It's a minor thing, but I thought I'd mention that the childless elements
in the example should look like this: "", and not "".
See: http://www.w3.org/TR/2000/REC-xml-20001006#sec-starttags


   RE: XML at start isn't well-formed Mike Moran 28.01.2001 15:09

&gt; It's a minor thing, but I thought I'd mention that the childless elements
&gt; in the example should look like this: "", and not "".
&gt; See: http://www.w3.org/TR/2000/REC-xml-20001006#sec-starttags

Looks like the XML example got munged. Maybe this will work:

"It's a minor thing, but I thought I'd mention that the childless elements
in the example should look like this: "&lt;foo/&gt;", and not "&lt;foo&gt;".
See: http://www.w3.org/TR/2000/REC-xml-20001006#sec-starttags


     RE: XML at start isn\'t well-formed Gunnstein Lye 20.08.2001 20:10

Fixed, thanks.




Forgot your password?

Register a new user

Results

Polls