Java. XML. how to validate certain part of xml document against XSD Schema? -


i have soap response web-service in string , document formats, , have method validates it. problem have validate node <result>.

i have got node, not know how child nodes tags , etc.

node result = (node)xpath.compile("//result").evaluate(xmldocument, xpathconstants.node);          <result>         <playerid>some id</playerid>         <partneruid>some partner uid</partneruid>         <registrationlevel>some registration level</registrationlevel>         <properties>            <property>               <key>some key</key>               <value>some value</value>            </property>            <property>...</property>         </result> 

thanks help

i validate xml file against xsd using way.i think you.

public string validatexmlschema() throws saxexception, ioexception {     file folder = new file("xsdpath");     file[] listoffiles = folder.listfiles();     string tempxsdfile;      for( int i=0; < listoffiles.length; i++ )     {         if(listoffiles[i].isfile())         {             tempxsdfile = listoffiles[i].getname();              try             {                 schemafactory factory = schemafactory.newinstance(xmlconstants.w3c_xml_schema_ns_uri);                  schema schema = factory.newschema(new file(xsdpath + tempxsdfile));                  validator validator = schema.newvalidator();                 validator.validate(new streamsource(new file("c://users//test.xml")));                 return tempxsdfile;             }             catch (ioexception | saxexception e)             {                 system.out.println("error: xml not known"+ e.getmessage());             }         }     }      return null; } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -