-3
我有一個來自Web服務的XML字符串,可能缺少一些子節點。驗證整個XML到預定義結構
解析XML之前,我想檢查所有的節點是否存在並正確。
例子:
<fields>
<field RandomAttribute="True"> //these attributes should not make a difference
<name>Test1</name>
<type>Text</type>
<id>123</id>
</field>
<field>
<name>Test2</name> //THIS field node lacks the "type" child node
<id>114</id>
</field>
</fields>
什麼是最好的方式,取整XML,並檢查所有節點是否符合預定義的XML模式/結構?
請注意,我向第一個FIELD節點添加了一個RandomAttribute,它不應該對功能產生任何影響。