Asiri Rathnayake wrote:
> On Wed, Nov 5, 2008 at 8:55 PM, Sergiu Dumitriu <[EMAIL PROTECTED]> wrote:
> 
>> Asiri Rathnayake wrote:
>>> On Wed, Nov 5, 2008 at 7:42 PM, Sergiu Dumitriu <[EMAIL PROTECTED]>
>> wrote:
>>>> Asiri Rathnayake wrote:
>>>>>> Isn't there a hasAttribute(attributeName) method? Just asking because
>>>>>> this method exists in the DOM Level 2 Core specification. See
>>>>>> http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-ElHasAttr
>>>>>>
>>>>> It's not available in org.w3c.dom.Node but org.w3c.dom.Element (which
>>>>> extends Node) contains that method. I don't see a way to use Element
>>>> instead
>>>>> of Node because Element doesn't seem to have a getChildElements()
>> method.
>>>> If Element extends Node, then it inherits all its methods, including
>>>> getChildElements.
>>>
>>> getChildElements() is not available in either Node or Element.
>>>
>>> May be I explained wrong. What I meant to say is, I can iterate over
>> Nodes
>>> in the dom tree, not Elements.
>>>
>> But you can always use instanceof and cast...
>>
> 
> I kind of thought of that. I mean in xhtml all tags should be Elements right
> ? But wasn't sure of this myself. And if the instanceof check fails, what
> should be the logic to handle that case ? Won't this complicate the code
> than it is now ?
> 

If the object is not instanceof Element, then you don't do anything.
Only elements can have attributes. The code won't be complicated.

-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
devs@xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to