Below code is to read xml file and verify if "ExpItemSeqNo" variable is present in the xml.
Public Function CXF_XML_Verification(ExpItemSeqNo)
Set doc = XMLUtil.CreateXML()
doc.LoadFile "C:\Abhi\Workplace\New Project Payments\CXF_641240000_17092012_193900_01_1.XML"
Set root = doc.GetRootElement()
Set children = root.ChildElements() 'Set child object for root.
chdrncount=children.count 'Getting child counts of root.
Print "Child count : "&chdrncount
Print "*******--------------------*************"
For j=1 to children.count
Set firstChild = children.Item(j) 'firstChild object is created to read item. This line is for first immediate child.
Set attribbes = firstChild.Attributes() 'To read attributes of immediate first child.
numOfAttr = attribbes.Count()
i=1 'To read only first attribute for all nodes.
'This loop is for reading all the attributes with the node "children.Item(j)"
' While i <= numOfAttr
Set attr = attribbes.Item(i)
nameStr = attr.Name()
valStr = attr.Value()
If (valStr = ExpItemSeqNo) Then
While i <= numOfAttr
'This will give you, attributes within node. in this case it is for first subsequent node.
Set Act_attr = attribbes.Item(i)
nameStrs = Act_attr.Name()
valStrs = Act_attr.Value()
attrStrs =attrStrs + nameStrs+" = "+chr(34)+valStrs+chr(34) + " " +chr(11)
i = i+1
Wend
'This will display sub childs node of any child node depending on j.
Print "Attributes: " + attrStrs
set firstChildName = firstChild.ChildElements()
Print "---------------------"
subchdrncount=firstChildName.Item(1)
Print subchdrncount
If (Instr(subchdrncount, "RSA_with_SHA256")<>0) Then
Print vbcrlf 'Add new empty line.
Print "Value exist in <AddendA "
End If
Print "*******-------------------------------"
subchdrncount=firstChildName.Item(2)
Print subchdrncount
If (Instr(subchdrncount, "RSA_with_SHA256")<>0) Then
Print vbcrlf
Print "Value exist in <<MICRDS "
End If
Print "*******-------------------------------"
subchdrncount=firstChildName.Item(3)
Print subchdrncount
If (Instr(subchdrncount, "RSA_with_SHA256")<>0) Then
Print vbcrlf
Print "Value exist in <ImageViewDetail "
End If
Print "*******-------------------------------"
subchdrncount=firstChildName.Item(4)
Print subchdrncount
If (Instr(subchdrncount, "RSA_with_SHA256")<>0) Then
Print vbcrlf
Print "Value exist in <ImageViewDetail "
End If
Print "*******-------------------------------"
subchdrncount=firstChildName.Item(5)
Print subchdrncount
If (Instr(subchdrncount, "RSA_with_SHA256")<>0) Then
Print vbcrlf
Print "Value exist in <ImageViewDetail "
End If
Print "*******-------------------------------"
print " "
End If
' attrStr = attrStr + nameStr+" = "+chr(34)+valStr+chr(34) + " " +chr(11)
attrStr = nameStr+" = "+chr(34)+valStr+chr(34) + " " +chr(32)
' i = i+1
' Wend
print "- "&j&" Attributes: " + attrStr
print "**********************************"&j
Next
End Function
-----------------------------------------
ExpItemSeqNo = "64100100000250"
call CXF_XML_Verification(ExpItemSeqNo)