How can I extract text from an xml file

I have an xml file which contains all the messages for a system monitor application. I've been asked to come with a way of automating a task to find out what files were deleted each day when a job runs. The status is held below in the xml file:

<Message id="8523" instanceId="2011/04/06-18:06:18.700_172.18.225.241_8523_Audio Watermark_E:\OspData\29-Dec-2010" status="Existing" severity="Informational" firstReceiveTime="2011-04-06T18:06:18.7005001+01:00">
              <Text>Audio Watermark disk manager last deleted folder E:\OspData\29-Dec-2010</Text>
                <Param type="String">Audio Watermark</Param>
                <Param type="String">E:\OspData\29-Dec-2010</Param>

What I'd like to do is have a script that will search for a value and then send the text in the next matching value to a text file.

I want to use the value Message id="8523" as the search field and then send the data in the <Param type="String">E:\OspData\29-Dec-2010</Param> to a text file.

I have the following from searching other sites but it creates an error and I don't know how to extract the second param type string info:

set xmlDoc=CreateObject("Microsoft.XMLDOM")
Application = xmlDoc.GetElementsByTagName("Message id="8523"").item(0).text
wscript.echo application
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

As long as the string you want is always the second param node some vbscript code like this should give you want you need.

Option Explicit
Dim objXMLDoc, xmlMessageNode, xmlParamNode, objFSO, objTextFile

Set objXMLDoc = CreateObject("MSXML2.DOMDocument")
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Text File to write the Data
Set objTextFile = objFSO.CreateTextFile("C:\extract.txt")

' Load the File

' Make sure we can find the node we want
If not objXMLDoc.selectSingleNode("//Message[@id = 8523]") is nothing then 
	Set xmlMessageNode = objXMLDoc.selectSingleNode("//Message[@id = 8523]")
End If

msgbox "Done"

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chrisdownesAuthor Commented:
wow absolutely brilliant, thanks for that.
chrisdownesAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.