2017年11月1日 星期三

vbnet XML 檢查節點

參考來源:Check if a node/element exists in an XML file
---
Dim vDoc As XmlDocument = New XmlDocument
vDoc.Load(pathToXml)
        Dim objTest As XmlElement
        objTest = vDoc.SelectSingleNode("//profileData/friends")
        If Not (objTest Is Nothing) Then
            'The node is present, do nothing
            Dim blank = ""
        Else
            'The node is absent, process code to create it.
            Dim xml = XDocument.Load(pathToXml)
            Dim vbfriends = From friends In xxml.
            vvbfriends(0).Add()
            xml.Save(pathToXml, SaveOptions.None)
        End If

沒有留言:

張貼留言