2 Replies Latest reply: Jun 27, 2008 7:41 AM by 807589 RSS

    Validating an XML string

    807589
      What is the most efficient way to validate an XML string with about 25 elements?

      I was going to do something like this, but I am not sure if its the most effienct way to
      validate the elements being passed.

      Basically, I want to put a message on a queue if one of the elements are null that is passed.

      Any suggestions, please let me know.

      Thanks!
      public String validateXmlString(String validate) throws Exception
      {
           DocumentImpl docXml = null;
           docXml = new DocumentImpl();
           docXml = XMLHlper.loadXMLFromString(validate);
      
           documentType = XMLHlper.getElementTextByName(docXml,"test:DOCUMENT_TYPE");
           indexClass = XMLHlper.getElementTextByName(docXml,"test:INDEX_CLASS");
           .
           .
           .
           .//about 25 elements
           
      
           if(documentType == null)
           {
                putMessageOnQueue("Error message");
           }
           else if(indexClass == null)
           {
                putMessageOnQueue("Error message");
           }
           .
           .
           .
           .//for all 25
      }