Convert .qml (QM file) to .xml

Functions, classes, components, etc. Only high quality content.

Convert .qml (QM file) to .xml

Postby Gintaras on Wed Jan 23, 2013 12:19 pm

2015-07-23. This will not work with files created with QM 2.4.0 and later.

Function QmlToXml     ?
;/
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     ?
;/
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"

Gintaras
Site Admin
 
Posts: 10299
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Convert .qml (QM file) to .xml

Postby ken gray on Wed Jan 23, 2013 5:48 pm

needed exactly this for email backup!!

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#
User avatar
ken gray
Active Member
 
Posts: 1711
Joined: Wed Feb 19, 2003 4:27 pm
Location: Minnesota, USA

Re: Convert .qml (QM file) to .xml

Postby ken gray on Thu Jan 24, 2013 2:03 pm

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...
User avatar
ken gray
Active Member
 
Posts: 1711
Joined: Wed Feb 19, 2003 4:27 pm
Location: Minnesota, USA

Re: Convert .qml (QM file) to .xml

Postby kaie26 on Thu Jul 23, 2015 11:18 am

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.
kaie26
 
Posts: 3
Joined: Fri Jul 17, 2015 7:53 am

Re: Convert .qml (QM file) to .xml

Postby Gintaras on Thu Jul 23, 2015 11:27 am

Now QM uses completely different file format. Now it is too difficult to convert to XML.
Gintaras
Site Admin
 
Posts: 10299
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Convert .qml (QM file) to .xml

Postby kaie26 on Thu Jul 23, 2015 11:39 am

Thanks for the info.
kaie26
 
Posts: 3
Joined: Fri Jul 17, 2015 7:53 am

Re: Convert .qml (QM file) to .xml

Postby Gintaras on Thu Jul 23, 2015 11:51 am

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
Gintaras
Site Admin
 
Posts: 10299
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Convert .qml (QM file) to .xml

Postby kaie26 on Sat Jul 25, 2015 4:04 am

thank you very much
kaie26
 
Posts: 3
Joined: Fri Jul 17, 2015 7:53 am


Return to QM Extensions

Who is online

Users browsing this forum: No registered users and 1 guest