Unanswered <xml> tag data is not updating in IE9

  • 9. dubna 2012 3:00
     
     

    In IE9 When I appendChild to the <xml> tag in HTML and after that I am testing it by printing the object data using innerHTML, its not updating i.e. it doesn't show the node which is added. 

    Basically, one of the dialog reads this xml data island and views data and that dialog is not updating, but when I refresh the whole page it updates. This works fine in other browsers. Could you please help me out.

    Thank you

Všechny reakce

  • 9. dubna 2012 4:42
     
     

    Hi,

    and your website address is?

    are you using jQuery? see bugs.jQuery.com. use value i/o innerHTML

    or

    see this search http://www.bing.com/search?q=xml+data+islands+w3schools


    Rob^_^

  • 9. dubna 2012 13:35
     
      Obsahuje kód

    Thanks for your reply. Its not a public website, sorry about that its an internal web app. 

    I'm not using jQuery, i'm using YUI. 

    I can post you little bit part of the code, see below

    var myXML = document.getElementById("XMLID");
    var xmlNode;
    var childNode;
    var tagNameElem;
    if(myXML) {
        if(window.DOMParser) {
          parser = new DOMParser();
          myXML = parser.parseFromString(myXML.innerHTML, "text/xml");
        tagNameElem = myXML.getElementsByTagName("ParentTagInsideXML");
    }
    //ChildNode is initialized, it will be something like
    //<data>SomeData</data>
    tagNameElem[0].appendChild(childNode);
    
    //After this when I print length of the data tags inside the parenttag it prints '1' like
    alert(tagNameElem[0].getElementsByTagName("data").length);
    
    //But when I print the Object data using innerHTML it //doesn't show the <data> tag like
    var example = document.getElementById("XMLID");
    alert(example.innerHTML);
    
    Thank you.


    nihar

  • 9. dubna 2012 20:28
     
     

    Hi,

    have you tried using the IE Developer tool to debug your page?

    F12>Script tab, click "Start Debugging"

    you have not included your childNode assignment in your mashup. Place a breakpoint in your production code and using the Developer tool's script console query the innerText of the childNode.... it may contain <> characters or is empty.

    regards.


    Rob^_^

  • 9. dubna 2012 20:57
     
      Obsahuje kód

    Thanks for your reply. 

    Basically, childNode is the one which is the responseXML and then the reference for that is passed into this function. please take a look at the below code

    function(object) { var childNodes_array = object.getElementsByTagName("TagToAdd");

    var childNode = childNodes_array[i]; }

    I have used the developer tool to debug, the childNode doesn't contain any innerText it only contains an attribute. when I checked the childNode.nodeName it gave me the correct tag name i.e. "TagToAdd". So, I'm sure that childNode is not empty. 

    In previous versions of IE also the xml data island is updated, For these I have checked using

    var example = document.getElementById("XMLID");
    alert(example.xml);

    it showed the updated content. but not in IE9. Please help me out.

    Thank you.


    nihar

  • 10. dubna 2012 1:15
     
      Obsahuje kód

    Hi,

    I don't beleive that you have used the Developer tools debugger.... your code snippets contains a number of errors that would fail.

    function(object) { var childNodes_array = object.getElementsByTagName("TagToAdd");

    var childNode = childNodes_array[i]; }

    functions have a return value.... varibles scoped within a function do not have global scope.

    Rob^_^

  • 10. dubna 2012 13:51
     
      Obsahuje kód

    Thanks for your reply.

    I'm sorry, i'm giving you the sample. Let me keep it properly

    function modifyXML(object)
    {
        var xmlNode;
        var childNode;
        var tagNameElem;
    
        var childNodes_array = object.getElementsByTagName("TagToAdd");
        childNode = childNodes_array[0];
    
        var myXML = document.getElementById("XMLID");
        if(myXML) 
        {
            if(window.DOMParser) 
            {
                parser = new DOMParser();
                myXML = parser.parseFromString(myXML.innerHTML, "text/xml");
            }
            tagNameElem = myXML.getElementsByTagName("ParentTagInsideXML");
            //ChildNode is initialized, it will be   //something like <data>SomeData</data>
            xmlNode = tagNameElem[0];
            xmlNode.appendChild(childNode);
    
            //After this when I print length of the data //tags inside the parenttag it prints '1' like
       alert(xmlNode.getElementsByTagName("data").length);
        }
        //But when I print the Object data using  //innerHTML it //doesn't show the <data> tag like
        var example = document.getElementById("XMLID");
    
        if(browser() == "IE")
            alert(example.xml);
        else
            alert(example.innerHTML);
    
        return xmlNode;
    }

    Please take a look at the above code, this would be clear. 

    Thanks


    nihar


    • Upravený Nihar17 10. dubna 2012 13:54
    •  
  • 12. dubna 2012 22:10
     
     

    sorry... I will leave your question for someone else to answer....

    unless you can provide a publicly accessibile link to the page or a mashup it is impossible for us to debug...

    most companies force intranet sites to use IE7 emulation in IE8 and above....

    add the x-ua IE=Edge to force your intranet sites to use 'Standards' mode... you should use the XMLSearializer not the DOMParser to parse xml.

    you can find a xml validator at w3schools.com or you can validate it at validator.w3.org by copy and paste into the direct input tab.


    Rob^_^

  • 13. dubna 2012 1:35
     
     

    var childNodes_array = object.getElementsByTagName("TagToAdd");
        childNode
    = childNodes_array[0];

    ?childNode.tagName

    TagToAdd

    try

    var childNode=document.createElement('TagToAdd');

    i/o

    var childNode;


    Rob^_^

  • 15. dubna 2012 17:42
     
      Obsahuje kód

    Thank you. I apologize for the late reply. I have made an example HTML page with a button, and when you click that you could see couple of alert popup boxes. Please see below.

    <!DOCTYPE html>
    <html>
    <body>
    <xml id="example">
    <parent>
    <data id="one" value="Folder"></data>
    </parent>
    </xml>
    <button onclick="modifyXML()">Hello</button>
    <script>
    function modifyXML()
    {
        var xmlNode;
        var childNode;
        var tagNameElem;
        
        childNode = document.createElement("data");
        childNode.setAttribute("id", "two");
        childNode.setAttribute("value", "File");
    
        var myXML = document.getElementById("example");
        if(myXML) 
        {
            if(getIEMode()>8 && window.DOMParser) 
            {
                parser = new DOMParser();
                myXML = parser.parseFromString(myXML.innerHTML, "text/xml");
            }
            tagNameElem = myXML.getElementsByTagName("parent");
            xmlNode = tagNameElem[0];		
            xmlNode.appendChild(childNode);                
        }
        alert("Length: " +xmlNode.getElementsByTagName("data").length);
    	
        //But when I print the Object data using innerHTML it doesn't show the second <data> tag
        var example = document.getElementById("example");
        alert("Result: " + example.innerHTML);
    	
    }
    
    function getIEMode()
    {
        var ver = document.documentMode;
        return ver;
    }
    </script>
    </body>
    </html>

    When you execute this in IE9 you could see the second alert box doesn't update with the new tag, but the length says 2. And it updates in other browsers like firefox and chrome. Please help me out.

    Thank you.




    nihar

  • 23. dubna 2012 19:19
     
     

    Could anybody please reply to my above question.

    Thank you.


    nihar