XML DOM vs. HTML DOM - Spare me XSLT

    Date: 07/09/07 (Javascript Community)    Keywords: browser, html, xml

    I have a deceptively simple problem.

    Using an XMLHTTPRequest object, I pull data off the server and grab it in the form of an XML Document object. As it happens, this data is actually well-formed XHTML. After I do some processing on this XML Document, I merely want to insert it into an output DIV tag.

    My initial instinct was to be as simple as possible: divTag.appendChild(xmlDoc);

    You might have already guessed- that doesn't work. Or, more accurately, it does work, exactly as it should. The code above appends the XML document object as XML data to the DIV. Which means the XHTML tags contained in the XML document are not interpreted by the browser.

    So, for illustration, I have an XML document like this:

    • Some data
    • Some more data


    I'd like to insert that XML data into a DIV, and have the browser recognize it as XHTML, and render it accordingly. It needs to be cross-platform. I'm not above turning it into a string and doing an innerHTML, but I'd really like to avoid that too.

    And while I'm poking with XML questions- I also need a cross-browser way of pulling an XML Document into a String- like the IE xmlDoc.xml property. I can't seem to find any property that makes Mozilla behave properly.

    Source: http://community.livejournal.com/javascript/135669.html

« Inserting
and a...
|| JavaScript Pong »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home