我給了一個XML文件,一個標籤包含多個屬性。但其中一個有時會跳過。 Exampe:如何使用SAX解析器檢查XML屬性是否存在?
<data>
<item attribute0="value 0" attribute1="value 1" attribute2="value 2">
<item attribute0="value 0" attribute1="value 1">
<item attribute0="value 0" attribute1="value 1" attribute2="value 2">
</data>
我使用SAX解析器來處理這個文件,並在startElement
方法,我讓所有的屬性值,但得到attribute2
之前,我需要檢查,如果它的存在。