Welcome to WebmasterWorld Guest from 54.166.179.165

Forum Moderators: httpwebwitch

Message Too Old, No Replies

How to Parse an XML Document?

     
8:39 pm on Nov 4, 2003 (gmt 0)

New User

10+ Year Member

joined:June 5, 2003
posts:39
votes: 0


first thing what does parsing an XML document means
Why it is used
How to Parse an XML document ...

I know how to work with XML tags ... i mean just started and can write a simle XML document /
what are other things one should know about XML as a web master ...

thanks

8:43 pm on Nov 4, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 20, 2002
posts:3732
votes: 0


Depends on what you need. To parse an XML document is to extract and read the information contained in that document. You can do this with server-side code like PHP or ASP. You can also use the XML stylesheet language XSL.

As a webmaster you may never have the need to use XML, but a lot of technology does use it. RSS feeds like the one dmoz uses to do a database dump is XML. It really depends on your goals technically.

9:02 pm on Nov 4, 2003 (gmt 0)

New User

10+ Year Member

joined:June 5, 2003
posts:39
votes: 0


i think XML was designed to describe the data and focus on what the data is ....it is widely used to structure, store and send information ...

when information is stored in XML we need to read that document .......... that is done through parsing ...
i wanted to know how it is done ... what xml objects are used to do that .....
i mean how is generally parsing done to read the huge documents and display it ../

thanks

9:09 pm on Nov 4, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 3, 2003
posts:960
votes: 0


This is an interesting question. I have often felt the need to parse XML documents, but I don't have a good XML background. Are there any good softwares available which take care to parse the xml documents in our desired format.
9:26 pm on Nov 4, 2003 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Mar 31, 2002
posts:7575
votes: 0


>> think XML was designed to describe the data

Precisely.

>> Why it is used

To make data portable independent of the medium that delivers it.

>> what are other things one should know

xml.com
oasis-open.org/cover/
oreilly.com

XML
SGML
Schemas
XSL/XSLT/XPath
XLink
XML Query
CSS
SVG

and about a hundred of ongoing projects [xml.coverpages.org]

How you parse is up to you. There are function libraries available for each of the major scripting languages (I know PHP has it and I'd guess ASP and CFML has it as well).

9:31 pm on Nov 4, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 13, 2002
posts:2162
votes: 0


Another way to read xml is to bind the xml data to an html table, using client side script.

See #7 for an example
[webmasterworld.com...]

9:44 pm on Nov 4, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 26, 2003
posts:881
votes: 0


when information is stored in XML we need to read that document .......... that is done through parsing ...
i wanted to know how it is done ... what xml objects are used to do that .....
i mean how is generally parsing done to read the huge documents and display it ..

Basic XML structure is...

<root> 
<children />
<children />
<children>
<subchildren />
</children>
...
</root>

Basic idea of parsing is to break the markup into a Document-Object Model (DOM) containing the various parts and their attributes, relationships, &c. This DOM can then be queried to get the various informations.

What is commonly meant when people talk about an 'XML parser' is just an engine that reads in an XML file and tries to build a DOM from it in a format that is accessible from whatever program is calling it, e.g., Xerces.

As mentioned, XSLT / XPath as well as PHP and other scripting languages, are are usually the programs used to query the DOM that was constructed by the parser. Depending on the programmer, the information that was retreived is then displayed in some common format such as XHTML + CSS, or PDF.

Jordan

1:57 pm on Nov 5, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 20, 2002
posts:3732
votes: 0


This thread may help:
[webmasterworld.com...]
2:50 pm on Nov 5, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Feb 27, 2003
posts:637
votes: 0


Korkus,
Great thread there! (The last post btw) I have been actively using xml/xsl/asp for about 2 years now, and have to say I love it totally.
Why it is used

Basically XML can be thought of as a container for data that then can be transferred between two systems.
How to Parse an XML document

I personally work with ht*p://msdn.microsoft.com/library/default.asp?url=/nhp/default.asp?contentid=28000438 (click on msxml -> sdk documentation -> and either msxml 4.0 or 3.0) for all of my parsing and transforming needs. I tend to use XSL to transform my data, instead of parsing with classic ASP.

Have fun! I do! ;)

Mac