4 Replies Latest reply on Aug 27, 2010 4:26 AM by Balakrishnan V

    XML Parsing error in Flex


      Hello Experts,


      I am passing a XML document form the Java to Flex using Remote Object.  My XML is as follows

      <dept ID="
      1" Name="RND"
          <Emp ID="
      1" Name="Aj"/>
      <dept ID="
      2" Name="ENG">
      <Emp ID="
      1" Name="Aj"/>
      <dept ID="
      3" Name="MECH">
          <Emp ID="
      1" Name="Aj"/>

      In Flex i am trying to access using below code


           treeData = event.result as XML;
      .dataProvider = treeData;

      I am getting the below exception and


      [RPC Fault faultString="org.w3c.dom.DOMException : INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. " faultCode="Server.Processing" faultDetail="null"]
          at mx
          at mx
          at mx
          at mx

      When i tried creating this XML locally and tried to access then i didn't faced any issue.


      Please help me to resolve this issue.
      Thanks in advance.


        • 1. Re: XML Parsing error in Flex
          flex4 Level 2



                    Is ur java class returning this xml object successfully.. once check it ... debug it and check it once then u can come to know what is the problem...

          • 2. Re: XML Parsing error in Flex
            flex4 Level 2



                       I think ur xml file name contains some illegal characters according to the dom.. please correct it and check it out once ... please feel free to check this link ..









            • 3. Re: XML Parsing error in Flex
              flex4 Level 2



                        I think this will help u





              DOMException.INVALID_CHARACTER_ERR (Error Code  5)


              W3C DOM Level 1


              A DOMException.INVALID_CHARACTER_ERR is thrown  whenever an                         invalid or illegal character is specified, such  as in a name.

              NOTE: Names in XML  can contain                         English letters (of any case), numbers (0-9),  underscores (_), periods(.)                         and hyphens (-). Names cannot begin with a  number, period or hyphen.                         Names can also contain a colon, but the use of  colons outside of namespaces                         should be avoided.

              XML for <SCRIPT> uses the following  regular expression to determin                         if a name is valid:


              function xmljsDOMExample() {
              var xml;
              xml = ""
              + "<?xml version=\"1.0\"?>"
              + "<ROOT>"
              + "<TAG1>"
              + "Hello"
              + "</TAG1>"
              + "</ROOT>";

              //instantiate the W3C DOM Parser
              var parser = new DOMImplementation();

              //load the XML into the parser and get the  DOMDocument
              var domDoc = parser.loadXML(xml);

              //get the root node
              var docRoot = domDoc.getDocumentElement();

              //The following should raise a  DOMException.INVALID_CHARACTER_ERR
              //because element names cannot contain the  "*" character
              try {
              catch (e) {
              if (e.code ==  DOMException.INVALID_CHARACTER_ERR) {
              //display the error message
              else {
              alert("unexpected exception");

              }// end function xmljsDOMExample
              • 4. Re: XML Parsing error in Flex
                Balakrishnan V Level 3



                This is a free xml validator, where you can give your XML URL or raw data from the response message and check it for errors - this gives error line numbers as well.


                I faced this issue a couple of weeks back; there was some issue with the double-quotes.


                Check and tell if this helps !


                Balakrishnan V