Basicfarmer
asked on
Extracting Data from an XML file
Experts, I am using the following code to get the message names and the values of text fields within a message <Message> which is in the attached file. What i need to do is change the text value of all fields of type "Text" for a given message. Then i want to extract that message into a string variable. Please show me an example of how to do this.
Dim xdoc As DOMDocument60, varLoop As Long, ciClass As ci1000, _
message As IXMLDOMElement, field As IXMLDOMElement
Set xdoc = New DOMDocument60
Set ciClass = main.printers(main.printerView.SelectedItem.Key)
xdoc.validateOnParse = False
If xdoc.Load("C:\Program Files\ID Technology\CiControl\Backup Files\" & _
main.printerView.SelectedItem.Key & "\" & _
Format(Date, "mm.dd.yy") & ".xml") Then
For Each message In xdoc.selectNodes("/CiControl/Messages/Message/Name")
Debug.Print message.Text
msgView.Nodes.Add , , "m" & message.Text, message.Text
If message.Text = ciClass.getStatus(9) Then
msgView.Nodes("m" & message.Text).Image = 1
Else
msgView.Nodes("m" & message.Text).Image = 2
End If
For Each field In xdoc.selectNodes("/CiControl/Messages/Message[Name='" & _
message.Text & "']/Field[Type='Text']/Text")
varLoop = varLoop + 1
msgView.Nodes.Add "m" & message.Text, tvwChild, "f" & field.Text, _
"Field: " & varLoop & ": " & field.Text, 3
Next
varLoop = 0
Next
Else
Dim errorStr As String, xpe As IXMLDOMParseError
Set xpe = xdoc.parseError
With xpe
errorStr = "There was an error loading the backup file! " & vbCrLf & _
"The backup file may be missing or corrupt. " & vbCrLf & _
"A backup of the system can be created manually " & vbCrLf & _
"in the system configuration form. " & vbCrLf & vbCrLf & _
"due the following error." & vbCrLf & _
"Error #: " & .errorCode & ": " & xpe.reason & _
"Line #: " & .Line & vbCrLf & _
"Line Position: " & .linepos & vbCrLf & _
"Position In File: " & .filepos & vbCrLf & _
"Source Text: " & .srcText & vbCrLf & _
"Document URL: " & .url
MsgBox errorStr, vbExclamation, "ID Technology"
End With
End If
Set ciClass = Nothing
Set xdoc = Nothing
11.04.13.xml
ASKER
Yes and i dont understand it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Why is this question still open? I solved the problem myself.
I will tell you one thing SouthMode. Have a nice day I'm gone. So feel free to feel better.
Regards
Friedrich