4 Replies Latest reply on May 4, 2015 6:30 AM by John Whitley

    XML not well formed under Internet Explorer

    John Whitley Newbie

      I have an application which works as expected under firefox or chrome.

      It has two radio buttons. Under internet explorer it displays OK until I click on the non-active radio button which cause a dialog box headed 'message from webpage' to appear with the message 'MalformedXML: Invalid Argument'.


      Does this message derive from internet explorer itself or is it application JavaScript generating the message?


      This is the xhtml of the form which is being updated

      <h:form id="payment">


          <h:outputText  value="How would you like to pay ? " />
          <h:selectOneRadio value="#{actController.paymentType}" id="paytype" layout="lineDirection"  immediate="true" >
              <f:selectItem itemValue="A" itemLabel="Customer Account" />
              <f:selectItem itemValue="C" itemLabel="Credit Card" />
              <f:ajax event="change" execute="@this" render="payment" />

      <!-- Payment on account  -->

              <h:panelGroup id="onaccount"  rendered="#{actController.renderAccount}">
                  <h:outputText  value="Account  " />


      <!-- Payment by card  -->

              <h:panelGrid  columns="2" id="bycard"  rendered="#{actController.renderCard}">
                  <h:outputText  value="Card  " />
                  <h:outputText  value="column  " />
              </h:panelGrid >
              <h:commandButton id="orderbutton" action="#{actController.order()}" style="float:right" value="Confirm"  disabled="#{not actController.confirmable}"/>



      If I run it with firebug under firefox, I can see this response to the click


      <?xml version='1.0' encoding='UTF-8'?>

      <partial-response id="j_id1"><changes><update id="payment"><![CDATA[

      <form id="payment" name="payment" method="post" action="/actjsf/index.jsf" enctype="application/x-www-form-urlencoded">

      <input type="hidden" name="payment" value="payment" />

          <p>How would you like to pay ? <table id="payment:paytype">



      <input type="radio" checked="checked" name="payment:paytype" id="payment:paytype:0" value="A" onchange

      ="mojarra.ab(this,event,'change','@this','payment')" /><label for="payment:paytype:0"> ACT Customer Account



      <input type="radio" name="payment:paytype" id="payment:paytype:1" value="C" onchange="mojarra.ab(this

      ,event,'change','@this','payment')" /><label for="payment:paytype:1"> Credit Card</label></td>




      <span id="payment:onaccount">Account  </span>


      <input id="payment:orderbutton" type="submit" name="payment:orderbutton" value="Confirm" style="float

      :right" disabled="disabled" />

      </form>]]></update><update id="j_id1:javax.faces.ViewState:0"><![CDATA[1193877744889537191:-93310910124109285

      ]]></update><extension id="org.richfaces.extension"><render>payment</render></extension></changes></partial-response



      Any suggestions?

        • 1. Re: XML not well formed under Internet Explorer
          Michal Petrov Master

          MalformedXML errors come from jsf.js But it's hard to tell what's causing you an try debugging the JavaScript to see what's wrong. Look for "sendError(request, context, "malformedXML", ex.message);" in jsf.js, I think that's the line that throws the exception.

          • 2. Re: XML not well formed under Internet Explorer
            John Whitley Newbie

            Thank you for the advice. I (think) I have pinned it down to this code in jsf.js:


            Starting at line 1462


                        } else if (html.length > 0) {
                            if (isAutoExec()) {
                                // Create html
                                parserElement.innerHTML = html;
                            } else {
                                // Get the scripts from the text
                                scripts = stripScripts(html);
                                // Remove scripts from text
                                html = html.replace(/<script[^>]*type="text\/javascript"*>([\S\s]*?)<\/script>/igm,"");
                                parserElement.innerHTML = html;
                            replaceNode(parserElement.firstChild, d);


            On firefox, the line 1471 parserElement.innerHTML = html also sets parserElement.firstChild allowing the 'replaceNode()' to succeed.


            On IE11, parserElement.firstChild is left as null, causing an exception in 'replaceNode'.


            Any suggestions as to a work around?


            Should I raise this on JIRA?

            • 3. Re: XML not well formed under Internet Explorer
              Michal Petrov Master

              Are you using any RichFaces components on your page? There aren't any in the code you pasted. This is ultimately an issue with IE but I wasn't able to reproduce it from your code. parserElement.firstChild should be <form>, I don't see why it would be null. (I've found a question on StackOverflow that deals with this but if I try creating a null firstChild I see EmptyTextNode instead)

              • 4. Re: XML not well formed under Internet Explorer
                John Whitley Newbie

                You are quite correct. I started with substantial amounts of richfaces components but I have stripped them progressively out to the point where it is just a <h:selectOneRadio> followed by alternatively rendered text (which did contain Richfaces components). I have tried the same snippet of html that IE is rejecting in a standalone page and it works as expected so it is presumably something to do with context.


                Thank you for your help. The stackoverflow link looks to be worth pursuing.