6 Replies Latest reply on Jun 8, 2007 2:07 PM by 807606

    String value being returned as an XML to be parsed.

      I have a 3rd Party Code API method which returns back
      an XML String.

      The value of this String is
      "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
           "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">" + "  " +
           "xmlns:i=\"http://www.Xan.com/interests:i\">" +
          "<i:Trade>" +
          "<i:Level>100000</i:Level>"     +
          "<i:Size>20000</i:Size>"        +
          "</i:Trade>"                  +
      I then need to convert this code back in XML format

      2)I then pass the above as a parameter to my own XML function
      private void buildXMLFromInputReceived(String underLyingCode){
                Document doc=null;
                try {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder documentbuilder = factory.newDocumentBuilder();
                doc = documentbuilder.parse(new ByteArrayInputStream(underLyingCode.getBytes()));
                //for Debug and View.
                XMLSerializer serializer = new XMLSerializer(System.out, new OutputFormat());
                }catch(Exception e){
                     logger.error("Unable to build XML " + e.toString());
      Upon execution this gives me the error:
      Fatal Error] :1:183: The prefix "i" for element "i:Level" is not bound.
      org.xml.sax.SAXParseException: The prefix "i" for element "i:Level" is not bound.
      The namespace has been defined in the String that contains the XML.

      So any idea why this error is coming.

      Please not that this is a 3rd Party API method call.