1. XML Document Operation 1.1 Load an XML Document DIM Objdoc As New XmLDocument () - Load XML Document Sample.xml Objdoc.Load ("Sample.xml") 1.2 Load an XML Data Dim Objdoc As New XMLDocument () DIM Strxml As string strXml = "
For example: objNode = objNode.selectsinglenode ("/ company / divartment / employees / employee) if not (objNode is nothing) THEN '- DO Process End If 2.2 Query Relative Path Node (Set) You can use the file path manner relative path to querying XML data objNode = objDoc.SelectSingleNode ( "Company / Department") objNodeList = objNode.SelectNodes ( "../ Department) objNode = objNode.SelectNode (" Employees / Employee ") 2.3 query known Nodes of the element name (set) When using an irregular hierarchy document, since it does not know the element name of the intermediate level, you can use the // symbol to cross the middle nodes, query all the other elements of the other elements, and many other elements. For example: objNodelist = objDoc.selectnodes 2.4 Element nodes (set), return properties, return properties, only need to adopt the corresponding method Pick up a @ symbol before the attribute name, for example: objNodelist = objdoc.selectnodes ("Company / Department / Employees / Employee / @ ID") ObjNodelist = Objdoc.selectNodes ("Company @ ID") 2.5 Query Text Node Use text () to get the Text node. ObjNode = ObjDoc.selectsinglenode ("Company / Department / Deparmt_name / text ()") 2.6 Querying the node of a particular condition using the [] symbol to query the node of a particular condition. For example: a. Return ID No. 10102 Employee Node ObjNode = Objdoc.selectsinglenode ("Company / Department / Employees / Employee [@ ID = '10102" ] ") B. Return Name to zhang qi Name Node ObjNode = Objdoc.selectsinglenode (" Company / Department / Employees / Employee / Name [Text () = 'zhang qi'] ") C. Return department contains staff 22345 Name Node ObjNode = Objdoc.selectsingLenode ("" Company / @ ID = '22345'] / divartment_name ") 2.7 Nodes for multi-mode Using | Symbols You can get multiple modes of multiple modes. For example: objNodeList = objdoc.selectnodes ("Company / Department / Department_name | Company / Department / Manager" 2.8 Querying Node Using * Symbols You can return all child nodes of the current node.