3 Replies Latest reply on Mar 27, 2009 8:54 PM by Newsgroup_User

    Xml parse failure

    Peter Hahmann
      Hi,

      I'm trying to parse the following xmlString, but as you'll notice, the parse will not be successful as one of my attributes has special chars. What can I do?

      Thanks,
      Peter


      my xmlString:

      <node><node id="01" label="Some text"><node id="02" label="Some text with < or >"/></node></node>
        • 1. Re: Xml parse failure
          _Natasha_ Level 4
          You can fix this xmlString by changing all special characters to there equivalent &lt; &gt; and others
          For example, you can get all attributes using RegExp
          var pattern:RegExp = /"([^"]*)"/g;
          var result:Object = testString.match(pattern);
          And then check each attribute for <,>, &, ... and replace incorrect values.
          I think it's the easiest way to solve it.
          • 2. Re: Xml parse failure
            ruffing232
            <node><node id="01" label="Some text"><node id="02" label="Some text with < or >"/></node></node>

            could become

            <node><node id="01" label="Some text"><node id="02" label="Some text with &lt; or &gt;"/></node></node>

            If your server is sending back the response, then you should probably fix this on the server side. This happens a lot when developers code their response using string builders instead of an XML node builder and then outputting the node.

            If you are just doing this on the client side, then the fix is to replace the XML markup characters with their equivalently coded characters.
            • 3. Re: Xml parse failure
              Level 7

              "ruffing232" <webforumsuser@macromedia.com> wrote in message
              news:gqjfam$gtq$1@forums.macromedia.com...
              > <node><node id="01" label="Some text"><node id="02" label="Some text with
              > < or
              >>"/></node></node>
              >
              > could become
              >
              > <node><node id="01" label="Some text"><node id="02" label="Some text with
              > < or
              >>"/></node></node>
              >
              > If your server is sending back the response, then you should probably fix
              > this
              > on the server side. This happens a lot when developers code their
              > response
              > using string builders instead of an XML node builder and then outputting
              > the
              > node.
              >
              > If you are just doing this on the client side, then the fix is to replace
              > the
              > XML markup characters with their equivalently coded characters.

              Or wrap the offending property in CDATA.