Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert .qml (QM file) to .xml
#1
2015-07-23. This will not work with files created with QM 2.4.0 and later.

Function QmlToXml
Code:
Copy      Help
;/
function $qmlFile $xmlFile

;Converts .qml (QM file) to .xml.

;qmlFile - .qml file. The function does not modify it.
;xmlFile - .xml file. The function creates or replaces it.

;REMARKS
;QM files are binary. Use this function if want to convert to text format.
;QM must be in Unicode mode.


if(!_unicode) end "QM must be in Unicode mode."

str s.getfile(qmlFile)
IXml x=CreateXml
lpstr sep="[][0][0]"

;header
int k j=findb(s sep 4)
if(!s.beg("//QM v2.") or j<0) goto ge
IXmlNode xr=x.Add("qml")
_s.left(s j); _s.encrypt(8)
xr.Add("header" _s)
xr.SetAttributeInt("version" 1)

;items
lpstr name triggerEtc flagsEtc folder text
rep
,j+4; if(j=s.len) break
,name=s+j
,triggerEtc=name+len(name)+1 ;;can contain not only trigger
,flagsEtc=triggerEtc+len(triggerEtc)+1 ;;flags[ date[ image]]
,folder=flagsEtc+len(flagsEtc)+1
,text=strstr(folder "[]"); if(!text) goto ge
,j=findb(s sep 4 text-s+2); if(j<0) goto ge
,
,IXmlNode xi=xr.Add("item")
,xi.SetAttribute("name" name)
,if(triggerEtc[0]) xi.SetAttribute("triggerEtc" triggerEtc)
,xi.SetAttribute("flagsEtc" flagsEtc)
,text[0]=0; xi.SetAttribute("folder" folder)
,text[0]=13; text[-1]='.'; xi.Value=text-1 ;;.[]text[] ;;. prevents removing empty lines

;x.ToString(_s); out _s
x.ToFile(xmlFile)

err+ end _error
ret
;ge
end "bad file format"

Function QmlFromXml
Code:
Copy      Help
;/
function $qmlFile $xmlFile

;Converts .xml file created by QmlToXml back to .qml format.

;qmlFile - .qml file. The function creates or replaces it.
;xmlFile - .xml file. The function does not modify it.

;REMARKS
;QM must be in Unicode mode.


if(!_unicode) end "QM must be in Unicode mode."

str s
IXml x=CreateXml
x.FromFile(xmlFile)
lpstr sep="[][0][0]"

IXmlNode xr=x.RootElement
if(xr.AttributeValueInt("version")!1) end "different version"

IXmlNode xi=xr.FirstChild
if(StrCompare(xi.Name "header")) goto ge
s.decrypt(8 xi.Value)
s.geta(sep 0 4)

rep
,xi=xi.Next; if(!xi) break
,if(StrCompare(xi.Name "item")) goto ge
,lpstr text=xi.Value; if(text[0]='.') text+1; else goto ge ;;prevent removing empty lines
,s.fromn(s s.len xi.AttributeValue("name") -1 "" 1 xi.AttributeValue("triggerEtc") -1 "" 1 xi.AttributeValue("flagsEtc") -1 "" 1 xi.AttributeValue("folder") -1 text -1 "[0]" 2)

;outb s s.len 1
s.setfile(qmlFile)

err+ end _error
ret
;ge
end "bad file format"
#2
needed exactly this for email backup!!

Quote:A problem occurred during the delivery of this message to this e-mail address. Try sending this message again. If the problem continues, please contact your helpdesk.


The following organization rejected your message: [74.125.142.26].


Diagnostic information for administrators:

Generating server: mail**.******************.***

******************@gmail.com
[74.125.142.26] #<[74.125.142.26] #5.0.0 smtp; 5.3.0 - Other mail system problem 552-'5.7.0 Our system detected an illegal attachment on your message. Please\n5.7.0 visit http://support.google.com/mail/bin/answ ... nswer=6590 to\n5.7.0 review our attachment guidelines. l5si3730312igo.4' (delivery attempts: 0)> #SMTP#
An old blog on QM coding and automation.

The Macro Hook
#3
Well...rats....it worked once and now Google is blocking the xml and text extensions via 3rd party main programs going to gmail account. BOOOOOO...
An old blog on QM coding and automation.

The Macro Hook
#4
Dear Gintaras,
I tried this function, but it did not work. Assuming I have a qml file: C:/source.qml and I want to convert it to C:/target.xml, how should I modify this code. Thank you in advance.
#5
Now QM uses completely different file format. Now it is too difficult to convert to XML.
#6
Thanks for the info.
#7
Now QM files are SQLite databases.
Some SQLite management programs can export to XML and maybe import too. I know these, but did not try exporting/importing:
1. SQLite Expert Pro can export. The free version can't.
http://www.sqliteexpert.com/features.html
2. SQLite Manager can export and import. It is a Firefox addition:
https://addons.mozilla.org/en-us/firefo ... e-manager/

See also SQLite convert tools:
http://www.sqlite.org/cvstrac/wiki?p=ConverterTools
SQLite management tools:
http://www.sqlite.org/cvstrac/wiki?p=ManagementTools
And google:
https://www.google.com/search?q=sqlite+ ... 8&oe=utf-8
#8
thank you very much


Forum Jump:


Users browsing this thread: 1 Guest(s)