Script to convert characters in XML file

Hello I have a folder that receives XML files that are pretty uniform across the board but messy I know its possible to edit the XML with VBS from this ipost and many others (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XML/Q_24756581.html?sfQueryTermInfo=1+edit+script+xml) I have never done this before and needed some help/

I need the following..... Snippet ID=598893

to chop out almost all the info and look allot cleaner like this.....

- <Document>
  <file_number>file number</file_number>
  <case_number>casenumber</case_number>
  <doc_name>W09-265-3811.pdf</doc_name>
  <doc_category>System</doc_category>
  <doc_source>Internal</doc_source>
  <doc_loc>W09-265-3811.pdf</doc_loc>
  <Document>
 
<?xml version="1.0" encoding="utf-8" standalone="no" ?> 
- <!-- ************************************************************
  --> 
- <!-- FILENAME:		K0224021.xml				
  --> 
- <!-- DESCRIPTION:	XML Release document			
  --> 
- <!-- 	 	 	with customizations.			
  --> 
- <!-- LAST MODIFIED:	4/8/2010				
  --> 
- <!-- ************************************************************
  --> 
  <!DOCTYPE kfx:XMLRELEASE (View Source for full doctype...)> 
- <kfx:XMLRELEASE xmlns:kfx="http://www.system.com/dtd/">
- <kfx:KOFAXXML>
- <kfx:BATCHCLASS ID="00000029" NAME="DocID">
- <kfx:DOCUMENTS>
- <kfx:DOCUMENT DOCID="00000EE3" DOCUMENTCLASSNAME="DocID">
- <kfx:DOCUMENTDATA>
  <kfx:DOCUMENTFIELD NAME="file_number" VALUE="W09-265" /> 
  <kfx:DOCUMENTFIELD NAME="case_number" VALUE="casenumber" /> 
  <kfx:DOCUMENTFIELD NAME="doc_name" VALUE="W09-265-3811.pdf" /> 
  <kfx:DOCUMENTFIELD NAME="doc_category" VALUE="CaseAware" /> 
  <kfx:DOCUMENTFIELD NAME="doc_source" VALUE="Internal" /> 
  <kfx:DOCUMENTFIELD NAME="doc_loc" VALUE="W09-265-3811.pdf" /> 
  </kfx:DOCUMENTDATA>
  <kfx:PRIMARYFILES /> 
  <kfx:SECONDARYFILES /> 
  <kfx:OCRTEXTFILES /> 
  </kfx:DOCUMENT>
  </kfx:DOCUMENTS>
  </kfx:BATCHCLASS>
  <kfx:BATCHSTATUS>Complete</kfx:BATCHSTATUS> 
  </kfx:KOFAXXML>
- <prefix:CUSTOMXML xmlns:prefix="www.test.com">
- <prefix:Document>
  <prefix:file_number>file number</prefix:file_number> 
  <prefix:case_number>case number</prefix:case_number> 
  <prefix:doc_name>W09-265-3811.pdf</prefix:doc_name> 
  <prefix:doc_category>system</prefix:doc_category> 
  <prefix:doc_source>Internal</prefix:doc_source> 
  <prefix:doc_loc>W09-265-3811.pdf</prefix:doc_loc> 
  </prefix:Document>
  </prefix:CUSTOMXML>
  </kfx:XMLRELEASE>

Open in new window

wirbicki2Asked:
Who is Participating?
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.

exx1976Commented:
This should do it.  Be sure to test first.

HTH,
exx
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oSource = oFS.OpenTextFile("c:\myxml.xml",1)
Set oTarget = oFS.CreateTextFile("c:\cleanxml.xml")
Write = False
Do While Not oSource.AtEndOfStream
	data = oSource.Readline
	If Write And InStr(LCase(data),"prefix:document") Then
		data = Replace(data,"prefix:","")
		Exit Do
	End If
	If Write Or InStr(LCase(data),"prefix:document") Then
		Write = True
		data = Replace(data,"prefix:","")
		oTarget.WriteLine(data)
	End If
Loop
oSource.Close
oTarget.Close

Open in new window

0
exx1976Commented:
Oops..  My apologies.  I forgot to write the last line in target file.  Use this code.

-exx
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oSource = oFS.OpenTextFile("c:\myxml.xml",1)
Set oTarget = oFS.CreateTextFile("c:\cleanxml.xml")
Write = False
Do While Not oSource.AtEndOfStream
	data = oSource.Readline
	If Write And InStr(LCase(data),"prefix:document") Then
		data = Replace(data,"prefix:","")
		oTarget.WriteLine(data)
		Exit Do
	End If
	If Write Or InStr(LCase(data),"prefix:document") Then
		Write = True
		data = Replace(data,"prefix:","")
		oTarget.WriteLine(data)
	End If
Loop
oSource.Close
oTarget.Close

Open in new window

0

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
wirbicki2Author Commented:
That's awesome thanks that got us on the right track thank you
0
exx1976Commented:
If it's awesome, then why a B?
0
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
XML

From novice to tech pro — start learning today.