我想用 java 編寫(xiě)一個(gè) xml 編輯器,并希望獲取 xml 元素的信息,例如可能的子元素、使用相應(yīng) xsd 的文檔。為了進(jìn)行驗(yàn)證,我可以使用這個(gè)簡(jiǎn)單的代碼片段,但我認(rèn)為它不能幫助我獲取 xml 中某一特定元素的信息: StreamSource[] schemaDocuments = { new StreamSource("layout.xsd") }; /* created by your application */; Source instanceDocument = new StreamSource("BEW.xml"); /* created by your application */; SchemaFactory sf = SchemaFactory.newInstance( "http://www.w3.org/2001/XMLSchema"); Schema s = sf.newSchema(schemaDocuments); Validator v = s.newValidator(); v.validate(instanceDocument);
如何從相應(yīng)的 xsd'S 獲取自己的 xml 編輯器的信息?
慕尼黑5688855
2024-01-05 16:49:10