How to get the text value of an XML node in IE8?

dsp_099

So I have an XML feed that returns a bunch of results. First I create an XML parser as outlined in faino's answer here.

The XML parses just fine. Every result looks like this:

<result>
 <title>some title</title>
 <bid>0.05123</bid>
 <description>some desc</description>
</result>

So I have:

// parse
var xmlParser = returnXMLParser();
var resultsDoc = xmlParser(adXML.responseData); // #document
var listings = resultsDoc.getElementsByTagName('listing'); // returns 8-10
// get title node
var title = listings[0].getElementsByTagName('title')[0];
title.nodeType // 1
title.nodeName // "title"

Here's the problem though, I have tried every property imaginable to get the inner text: textConent, innerText, innerHTML, nodeValue - none of them seem to work in IE8.

The same script works perfectly fine in Chrome / FF using .textContent

Help!

Mouser

A cross-browser backwards-compatible script:

function getXMLContent(obj,action)
{

    //cross-browser get and set for xmlContent
    if (obj)
    {
        if (action == "get") //get
        {
            if(obj.textContent)
            {
                return obj.textContent;
            }
            else
            {
                return obj.text;
            }
        }
        else //set
        {
            if(obj.textContent)
            {
                obj.textContent = action;
            }
            else
            {
                obj.text = action;
            }
        }
    }
    else
    {
        throw new Error("XML-Element doesn't exist.");
    }
}

In my own AJAX-calls where I retrieve XML I always use this function to retrieve to content of the node.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get the xml node value in string

From Dev

How to get the last node value in xml

From Dev

How to get the last node value in xml

From Dev

How to get the xml node value into a string

From Dev

text value of xml node into java

From Dev

Unable to get value from loop in IE8

From Dev

c++ How to retrieve a text value from an XML node

From Dev

How to get xml Node name and Inner Text and Fill Grid view

From Dev

Get XML Node Text using LINQ To XML

From Dev

Get text node value in DOM

From Dev

XML to dataframe How to get a default value if node does not exist

From Dev

How to get xml node value by using xelement in c#

From Dev

How to parse SOAP xml to get the value of a certain node

From Dev

XML to dataframe How to get a default value if node does not exist

From Dev

how to get html2canvas working in ie8?

From Dev

how to get rid of certificate error: navigation blocked in ie8

From Dev

How to get a value of XML

From Dev

XML node and text value. Is this right?

From Dev

In Scala, how do I get the text of a XML node without the text of its subnodes?

From Dev

Get the text only part of an xml node

From Dev

How do you get a node that contains a child node with a given attribute value in an XML document using sql server?

From Dev

Get Node value from a XML using xmllint

From Dev

Get node value in XML using jQuery

From Dev

Get node value with HTML in XML via PHP

From Dev

Can't get value of xml node

From Dev

Ruby- get a xml node value

From Dev

Get XML Child Node Value from soapxml

From Dev

XML Get Value from Node C#

From Dev

C# Get XML Node Value