Re: javascript and XML help
- From: rbann11@xxxxxxxxxxx
- Date: 25 Jul 2006 08:24:36 -0700
Martin Honnen wrote:
rbann11@xxxxxxxxxxx wrote:
My question is what is the best way to parse the XML string and can it
be done with DOM.
<root>^^^^^
Some Text and html tags
<block a="1 "b="2">
That is not well-formed XML so any XML parser will give a parse error.
Some Text and html tags
<block>
Some Text and html tags
<tag1> </tag1>
<tag2> </tag2>
<tag3> </tag3>
<tag3> </tag4>
</block>
<block a="4">
Some Text and html tags
<tag1> </tag1>
<tag2> </tag2>
</block>
</block>
Some Text and html tags
</root>
If you want to parse XML from a string then look into
<http://www.faqts.com/knowledge_base/view.phtml/aid/15302/fid/616>
You need to be aware however that such an XML parsing will give you XML
DOM nodes, it does not help that some of them might have the same tag
name as HTML elements e.g.
<root>
<p><strong>Kibo</strong> is God.<p>
</root>
will parse root as well as p or strong into an XML DOM element node. And
those XML DOM element nodes do not become HTML DOM element nodes later
if you try to insert them into an HTML DOM document to have them rendered.
With browsers like Mozilla or Opera which have a common DOM
implementation beneath their HTML and XML parsers you could get XHTML
DOM nodes by using the proper XHTML namespace e.g.
<root>
<p xmlns="http://www.w3.org/1999/xhtml"><strong>Kibo</strong> is
God.<p>
</root>
that way the XML parser will create XHTML element nodes for those
elements in the XHTML namespace and these nodes can then be imported and
rendered in a HTML DOM document.
But IE has separate HTML and XML parsers and DOM implementations so its
XML parser will not do anything special with elements in the XHTML
namespace.
--
Martin Honnen
http://JavaScript.FAQTs.com/
Thanks for replying.
Actually, I misunderstood DOM. It does what I want it to.
Keep up the good work,
Roger
.
- References:
- javascript and XML help
- From: rbann11
- Re: javascript and XML help
- From: Martin Honnen
- javascript and XML help
- Prev by Date: Re: Set the url as "Trusted" in IE through javascript
- Next by Date: Re: stack overflow on 1 PC and not on another?
- Previous by thread: Re: javascript and XML help
- Next by thread: get url from onbeforeunload object
- Index(es):
Relevant Pages
|