Jeremy Holbrook
asked on
How to convert an XML Base64 file into a text document
I have a large .xml file that has base64 code in it. I am not a programmer but I have a little bit of VBScript knowledge. I am trying to figure out how to parse out the base64 code and convert it into a text document. There is about 12,000 lines in the document. Here is an example of what I have:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Dates>
<Date DateId="162" Type="Text" Value="2016-11-15">
<Revisions>
<Revision Value="0">
<Account Application="Info">
<Pages PageCount="3">
<Page>
<PageNumber>1</PageNumber>
<Content Encoding="Base64">DQogDQog DQo.....</ Content>
</Page>
<Page>
<PageNumber>2</PageNumber>
Any help would be appreciated.
Thanks,
Jeremy
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Dates>
<Date DateId="162" Type="Text" Value="2016-11-15">
<Revisions>
<Revision Value="0">
<Account Application="Info">
<Pages PageCount="3">
<Page>
<PageNumber>1</PageNumber>
<Content Encoding="Base64">DQogDQog
</Page>
<Page>
<PageNumber>2</PageNumber>
Any help would be appreciated.
Thanks,
Jeremy
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Unfortunately the https://www.base64code.org can't handle but a small bit of information, and my document is 12,000 lines - otherwise yes this option would work
Wow, your lines must be quite long too, because I was able to encode and decode more than 1MB of data with no problem.
Anyway, if that didn't work, try this one...
http://www.freeformatter.com/base64-encoder.html
If you cut just the base64 content out and paste into it's own file, and then with the above site you can upload that file. I'm guessing this will mean that it can handle a bigger input size.
You pass the base64 string from the XML element to the function and it returns the decoded string
ASKER
Thank you for your help.
ASKER
The function looks very promising I am just not sure how to tie it into the vbscript.
Here is what I have so far but its pulling the wrong info (I am getting everything but the base64) - I want it to pull the base64 code out of the xml and then convert it.
set objFSO=CreateObject("Scrip
filename = "2016-11-15.xml"
outFile = "converted.txt"
Set fso = CreateObject("Scripting.Fi
Set f = fso.OpenTextFile(filename)
Set objFile = objFSO.CreateTextFile(outF
Do Until f.AtEndOfStream
strLine=f.ReadLine
If InStr(strLine, "DQo") = 0 Then
objFile.Write strLine & vbCrLf
End If
Loop
Function Base64Decode(ByVal vCode)
Dim objDocument
Dim objNode
Dim b
Set objDocument = CreateObject("MSXML2.DOMDo
Set objNode = objDocument.createElement(
objNode.DataType = "bin.base64"
oNode.Text = vCode
Base64Decode = StrConv(oNode.nodeTypedVal
End Function
objFile.Close
f.Close