[jdev] Child nodes of DOM Attr

Joonas Govenius joonas.govenius at gmail.com
Mon Sep 17 20:20:58 CDT 2007

On 9/17/07, Joonas Govenius <joonas.govenius at gmail.com> wrote:
> Hi all,
> I ran into this problem with the Qt DOM implementation when writing
> some code for shared XML editing:
> If I try to insert a DOM Text node to a DOM Attr node using
> appendChild(), nothing happens. Does anyone know for sure whether
> that's the correct behavior?

I guess this is standard. Firefox tells me "Modifications are not
allowed for this document" if I try to do this with JavaScript:

    var attr = document.createAttribute("style");
    var text = document.createTextNode("font-style: italic;");

> http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-637646024 mentions:
>   In XML, where the value of an attribute can
>   contain entity references, the child nodes of
>   the Attr node may be either Text or
>   EntityReference nodes...
> How are you supposed to add (several of) these nodes if not with appendChild()?

I guess I'll just serialize them into a string and set that as the nodeValue.


More information about the JDev mailing list