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

    XML Parsing error in Flex

    ajk74 Level 1

      Hello Experts,

       

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

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

      In Flex i am trying to access using below code

       

           treeData = event.result as XML;
           deptTree
      .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
      .rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
          at mx
      .rpc::Responder/fault()
          at mx
      .rpc::AsyncRequest/fault()
          at
      NetConnectionMessageResponder/statusHandler()
          at mx
      .messaging::MessageResponder/status()


      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.

      Aj

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

          Hi

           

                    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

            Hi

             

                       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 ..

             

             

             

                             http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4913257

             

             

               Thanks

            Ram

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

              Hi

               

                        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:

              /^[a-zA-Z_:][a-zA-Z0-9\.\-_:]*$/

              Example:
              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 {
              domDoc.createElement("***");
              }
              catch (e) {
              if (e.code ==  DOMException.INVALID_CHARACTER_ERR) {
              //display the error message
              alert(parser.translateErrCode(e.code));
              }
              else {
              alert("unexpected exception");
              alert(e.code);
              }
              }

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

                http://www.w3schools.com/XML/xml_validator.asp

                 

                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