|
lz可以试试找到值以后再替换吗?
如题。
/* Code Dummy */
xfile The file name (including its path)
epath The path containing the child elements you want to retrieve
eleName The name of the attribute to idenify the right element
attrValue The value of the attribute to identify the right element
Public Function ChangeAttributeValue(xfile, epath, attrName, attrValue)
' Create and load the XML file
Set doc = XMLUtil.CreateXML()
doc.LoadFile xfile
Set elementCol = doc.ChildElementsByPath(epath)
' Search through the nodes for the child you want.
for i = 1 to elementCol.Count
set attribs = elementCol.Item(i).Attributes
for x = 1 to attribs.Count
set attr = attribs.Item(x)
' If the specified attribute does not match the one you are looking for, continue with the next iteration.
If StrComp(attrName,attr.Value) <> 0 then
Exit For
End if
' Specified child element found, retrieve the desired value.
Set attrib = attribs.ItemByName(attrValue)
If attrib is nothing Then
ChangeAttributeValue = "Attribute not found"
else
attrib.Value = ......
End If
Exit Function
Next
Next
' The child node was not found.
RetrieveAttributeValue = "Attribute not found"
End Function
希望有帮助。 |
|