建议楼主在生成xml文档前进行数据验证。 这样可以保证数据的有效性。 
何必要在生成XML文档后再来验证呢?况且jsp 中的xml文档在js中是不能引用的,也就是说js中是没办法来操作jsp 中的xml文档。
只有提交到服务器中来验证。这样一来,效率就慢了,还不如在生成xml文档前进性验证工作。另外请教一下, schema是java中内置的包吗?怎么我查不到

解决方案 »

  1.   

    validateOnParse Property
    Indicates whether the parser should validate this document.Res
    Boolean. The property is read/write. If True, it validates during parsing. If False, it parses only for well-formed XML. The default is True.This member is an extension of the Worldwide Web Consortium (W3C) Document Object Model (DOM).[Script] 
    Script Syntax
    boolValue = oXMLDOMDocument.validateOnParse;
    objXMLDOMDocument.validateOnParse = boolValue;
    Example
    var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
    xmlDoc.async = false;
    xmlDoc.validateOnParse = true;
    xmlDoc.load("books.xml");
      

  2.   

    Oh, sorry. I forgot to tell you that "validateOnParse Property" has nothing to do with schema, but dtd, I think you should try dtd to verify your xml.