检查vbscript中的xml节点是否为空

时间:2011-10-19 06:47:33

标签: xml vbscript

鉴于以下XML,我将如何检查特定节点是否为空。例如<sale_price></sale_price>

我想要做的是有一个if语句,如果节点为空则运行一些代码,如果不是则跳过它。

<?xml version="1.0" encoding="iso-8859-1"?>
    <Export>
        <SAVED_EXPORT>
             <id>00-6189</id>
             <price>5.46 USD</price>
             <sale_price></sale_price>
         </SAVED_EXPORT>
    </Export>

1 个答案:

答案 0 :(得分:3)

Set oNode=oXML.selectSingleNode("//Export/SAVED_EXPORT/sale_price/")
If not(oNode is nothing) then 
   If oNode.Text="" Then

   End If
End If