Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Few Questions about org.w3c.dom.Element

From: Joshua Cranmer <Pidgeot18@-------.------->
To: NULL
Date: 4/10/2008 9:40:00 PM

RC wrote:
> In that org.w3c.dom.Element interface

Ah, so this is a question on the DOM.

> I can getTagName()
> But
> 1) How do I do know is it an empty tag or not?
> 
> <tag ..... />

<tag></tag> and <tag /> are the same thing as far as the DOM is closed.
That is the job of the parser, and is generally not important. However,
one can detect a state equivalent to said tag by checking for any
children of node type TEXT_NODE.

> 2) How do I know when will be a close tag?
> 
> <tag1>
> <tag2>xxxx</tag2>
> <tag3 ..... />
> <tag4 ..... />xxxxx</tag4>
> ......
> </tag1>

You seem to be parsing XML. The DOM is wholly an in-memory
representation, whereas XML is a text format representation of the same
tree. Therefore no close tags exist in the DOM. The example you give
will be noted in the DOM as such:

Element tag1
|
+-- Element tag2
|   |
|   +-- Text node "xxxx"
|
+-- Element tag3
|   |
|   +-- Attribute attr1 value val1
|
+-- Element tag4
|   |
|   +-- Attribute attr1 value val1
|   |
|   +-- Text node "xxxxx"
|
< other elements, text nodes, etc. >

No close tags are needed nor involved.

-- 
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent