473,402 Members | 2,046 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,402 software developers and data experts.

can anyone tell me the DOM structure of a XML doc?

dmjpro
2,476 2GB
i want a good link on XML DOM ...

i mean how can i do XML parsing using JS as DOM in HTML page.
plz help.

kind regards.
dmjpro.
May 12 '07 #1
3 1146
gits
5,390 Expert Mod 4TB
hi ...

i hope i don't misunderstand your question ... but i think you are able to use the same dom-methods for xml as for html ... for example we use them for all of our xul-apps ... and xul is xml too ;) ... so all the getElement...-methods, setAttribute, removeAttribute, etc. functions will work ... for retrieving and manipulating the xml-dom ... or doesn't this solve your problem?
May 12 '07 #2
dmjpro
2,476 2GB
it would be better if u explain with a tree structure with the help of a XML DOC.

anyway, thanx for ur reply.
kind regards.
dmjpro.
May 13 '07 #3
gits
5,390 Expert Mod 4TB
ok ... let me try it ;)

assuming we have the following typical and simple xml-document:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" standalone="no" ?>
  2. <!DOCTYPE message SYSTEM "message.dtd">
  3. <message>
  4.     <from>The Kenster</from>
  5.     <to>Silly Little Cowgirl</to>
  6.     <body>
  7.         Hi, there. How is your gardening going?
  8.     </body>
  9. </message>
  10.  
the first line says that we have a xml-document of version 1.0 and that this document is associated by a DTD (document type definition) that describes the structure of the document (which elements are valid, what elements may be contained by which elements, which of them must be contained, how often they have to be contained ... which attributes are mandatory etc.) ... it may also (should) have an encoding attribute.

the second line refers the mentioned DTD and the root-element 'message'.

then the interesting part now, often called the docs body or payload of the doc ... the one to parse :) you get the 'message'-node as an instance of a message with the childNodes from, to and body ... so you have the data for your message ... assuming you have multiple messages you probably would have a root-element called 'messagelist' that has to be specified in the DTD when having one ... note: the DTD is optional, but required if you want to validate your document against it ... so there is now a next point:

an xml-doc is well-formed if it is syntactically correct ...
an xm-doc is valid when it is validated against a DTD and correct in that way

'well-formedness' is required ... validity is not ...

so you may access the elements in the document with regular dom-methods ... for example:

Expand|Select|Wrap|Line Numbers
  1. var messages = document.getElementsByTagName('message');
  2.  
  3. for (var i in messages) {
  4.     // you may now access one message's childNodes with
  5.     // known methods, navigating through it with siblings etc.
  6. }
  7.  
may be the following links could help too:

http://www.w3schools.com/dom/default.asp
http://www.stylusstudio.com/docs/v60/d_xpath9.html
http://www.awprofessional.com/articles/article.asp?p=27006&seqNum=3&rl=1

the last one has a very good explaination ...

i hope it helps more ... and kind regards ...
May 13 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: AF | last post by:
XOOPS - Anyone using it? What do you think of it? Thanks. Cheers to everyone, Al http://www.discountdrivingschool.com
5
by: Clifford W. Racz | last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML) into xHTML? I have been trying to get the nested table code for my XSLT to work for a while now, with no way to get the...
11
by: Robert Schuldenfrei | last post by:
I am an older person trying to learn C# just for the fun of it. I am a veteran of older style languages (COBOL, FORTRAN, etc.) and I want to learn an Object Orientated language. Currently working...
2
by: Jeff Brown | last post by:
OK i removed all of my datasets to start fromo scratch again with another method. Is there a way i can create all my datasets in the MDI Parent form and reference them from child forms...
1
by: Brian Worth | last post by:
Hi, I've just upgraded a program from VB4 to VB .NET 2002. The program would use the GetCurrentHWProfile API to tell if my laptop was docked or undocked. I've tried converting this call without...
7
by: iwdu15 | last post by:
how can i tell if my system has gone idle? then how can i execute a command accordingly? thnks
10
by: Extremest | last post by:
I know there are ways to make this a lot faster. Any newsreader does this in seconds. I don't know how they do it and I am very new to c#. If anyone knows a faster way please let me know. All...
9
by: Coleen | last post by:
Hi All :-) I am desperately looking for some help/information on how to direct page flow. Forget what I have done - here's what I need to do: I have a large ASPX.Net - VB.Net web application...
5
by: hardik | last post by:
hi friends i need help in this sql query i have table like, id fid __ _____ autonumber text and i am storing values like
10
by: chat | last post by:
Hi, I know that text file ended with EOF mark but there is no mark for binary file. So, the problem is how do we know the end of binary file is reach? This code can tell us when the end of file...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...

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.