Click to See Complete Forum and Search --> : Programming Challenge


ille_pugil42
11-17-2000, 04:00 PM
Okay, here's the issue. I have to use MSN explorer at work and it has a very evil favorites listing. It lists all favorites in reverse order, as in the fav added last is on top. The acutal file is in a very ugly xml variant. Think anyone is able to create a proggy to be able to parse this file? Preferably runnable in Linux (will download the file and proggy at home, update the fav's and then upload my favs back to work)... here's the file:

<?xml version="1.0" encoding="utf-8"?>
<favorites><favfolder created="2000-11-17T17:55" title="programming" id="(R6tR1M0p`Jh[Eb4?/Eh"><favorite lv="2000-11-17T17:56" vc="2" id="(R6tR.Dr:4K:n)V{H[Hl"><title>Planet Source Code</title><href>http://www.planet-source-code.com/</href><created>2000-11-17T17:55</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.planet-source-code.com/"/><propbag sect="DOC#1037" prop="BASEURL" val="http://www.burstnet.com/cgi-bin/ads/ba2674a.cgi/RETURN-CODE/if/2000111712525251/"/><propbag sect="DOC#1037" prop="ORIGURL" val="http://www.burstnet.com/cgi-bin/ads/ba2674a.cgi/RETURN-CODE/if/2000111712525251/"/></favorite><favorite lv="2000-11-17T17:55" vc="1" id="(R6tR0/Hfl(aswTrYiS{"><title>Visual Basic World</title><href>http://www.vbworld.com/</href><created>2000-11-17T17:55</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.vbworld.com/"/></favorite></favfolder><favfolder created="2000-11-17T14:56" title="temp" id="(R6t;;2|`8?vOLSv4ZfI"><favorite lv="2000-11-17T17:51" vc="3" id="(R6t;9},Zt)dzF./`j]>"><title>New X Desktop Thread - Linuxnewbie.org BBS</title><href>http://www.linuxnewbie.org/ubb/Forum6/HTML/002288.html</href><created>2000-11-17T14:56</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.linuxnewbie.org/ubb/Forum6/HTML/002288.html"/><propbag sect="DOC#23" prop="BASEURL" val="http://netadsrv.iworld.com/html.ng/site=internetcom&PagePos=10&size=468x60&channel=li nux&content_site=www.linuxnewbie.org&feature=FEATU RE"/><propbag sect="DOC#23" prop="ORIGURL" val="http://netadsrv.iworld.com/html.ng/site=internetcom&PagePos=10&size=468x60&channel=li nux&content_site=www.linuxnewbie.org&feature=FEATU RE"/><propbag sect="DOC#23#4" prop="BASEURL" val="http://ads.enliven.com/tools/igen.dll?session=240818502;euid=133444695;type=ifr ame;cid=196409;sid=25900;click="/><propbag sect="DOC#23#4" prop="ORIGURL" val="http://ads.enliven.com/nc/rd?type=iframe;cid=196409;sid=25900;click="/><propbag sect="DOC#269" prop="BASEURL" val="http://netadsrv.iworld.com/html.ng/site=internetcom&PagePos=20&size=468x60&channel=li nux&content_site=www.linuxnewbie.org&feature=FEATU RE"/><propbag sect="DOC#269" prop="ORIGURL" val="http://netadsrv.iworld.com/html.ng/site=internetcom&PagePos=20&size=468x60&channel=li nux&content_site=www.linuxnewbie.org&feature=FEATU RE"/></favorit e></favfolder><favfolder created="2000-11-17T14:30" title="linux" id="(R6t7x/yS:5`Si\bhgKm"><favfolder created="2000-11-17T14:42" title="download/misc" id="(R6t9J[>4@gUQe;N61h-"><favorite lv="2000-11-17T14:36" vc="1" id="(R6t8^KO+rd1}=@xYXjo"><title>LDP</title><href>http://csociety-ftp.ecn.purdue.edu/LDP/sorted_howtos_title.html</href><created>2000-11-17T14:36&l t;/created><propbag sect="DEFAULT" prop="BASEURL" val="http://csociety-ftp.ecn.purdue.edu/LDP/sorted_howtos_title.html"/></favorite><favorite lv="2000-11-17T17:45" vc="3" id="(R6pD[V}UFHECdAD3\5W"><title>/.</title><href>http://www.slashdot.com/</href><created>2000-11-15T19:12</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.slashdot.com/"/></favorite><favorite lv="2000-11-17T14:36" vc="1" id="(R6t8esTF\bZ8xwUdGFv"><title>[fm]</title><href>http://freshmeat.net/</href><created>2000-11-17T14:36</created><propbag sect="DEFAULT" prop="BASEURL" val="http://freshmeat.net/"/></favorite><favorite lv="2000-11-17T14:36" vc="1" id="(R6t8dDPmZKu_I|z}BWk"><title>Tucows</title><href>http://viclink.linux.tucows.com/index.html</href><created>2000-11-17T14:36</created>< propbag sect="DEFAULT" prop="BASEURL" val="http://viclink.linux.tucows.com/index.html"/></favorite><favorite lv="2000-11-15T19:19" vc="1" id="(R6pEO_MBPiMkeFd,n,a"><title>linuxmail.org</title><href>http://www.linuxmail.org/</href><created>2000-11-15T19:19</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.linuxmail.org/"/></favorite><favorite lv="2000-11-17T14:43" vc="2" id="(R6r3609iNR8d/^)NA@5"><title>LNO</title><href>http://www.linuxnewbie.org/</href><created>2000-11-16T15:24</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.linuxnewbie.org/"/><propbag sect="DOC#29" prop="BASEURL" val="http://netadsrv.iworld.com/html.ng/site=internetcom&PagePos=10&size=468x60&channel=li nux&content_site=www.linuxnewbie.org&feature=FEATU RE"/><propbag sect="DOC#29" prop="ORIGURL" val="http://netadsrv.iworld.com/html.ng/site=internetcom&PagePos=10&size=468x60&channel=li nux&content_site=www.linuxnewbie.org&feature=FEATU RE"/></favorit e></favfolder><favfolder created="2000-11-17T14:40" title="desktop environs" id="(R6t94w>]j`0VfpMAV><"><favorite lv="2000-11-17T14:37" vc="1" id="(R6t8gmjuj4bjbWbv`4@"><title>Kde</title><href>http://www.kde.org/</href><created>2000-11-17T14:37</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.kde.org/"/></favorite><favorite lv="2000-11-17T14:36" vc="1" id="(R6t8fa-44Dj<HHgns_q"><title>GNOME</title><href>http://www.gnome.org/</href><created>2000-11-17T14:36</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.gnome.org/"/></favorite></favfolder><favfolder created="2000-11-17T14:40" title="wm" id="(R6t93lhL`kM;GTR9=NO"><favorite lv="2000-11-17T14:37" vc="1" id="(R6t8lZ<NDo\;}gs|QPY"><title>icewm</title><href>http://icewm.sourceforge.net/</href><created>2000-11-17T14:37</created><propbag sect="DEFAULT" prop="BASEURL" val="http://icewm.sourceforge.net/"/></favorite><favorite lv="2000-11-17T14:37" vc="1" id="(R6t8kSS:He;a^cncwO>"><title>Sawfish</title><href>http://www.sawfish.org/</href><created>2000-11-17T14:37</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.sawfish.org/"/></favorite><favorite lv="2000-11-17T14:37" vc="1" id="(R6t8jZO|tf|Nm?9F4\S"><title>Blackbox</title><href>http://blackbox.alug.org/</href><created>2000-11-17T14:37</created><propbag sect="DEFAULT" prop="BASEURL" val="http://blackbox.alug.org/"/></favorite><favorite lv="2000-11-17T14:37" vc="1" id="(R6t8ickrH7a>0aBMuJB"><title>AfterStep</title><href>http://www.afterstep.org/</href><created>2000-11-17T14:37</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.afterstep.org/"/></favorite><favorite lv="2000-11-17T14:37" vc="1" id="(R6t8hqbKFIf-TK[]d.}"><title>Enlightenment</title><href>http://www.enlightenment.org/</href><created>2000-11-17T14:37</created><propba g sect="DEFAULT" prop="BASEURL" val="http://www.enlightenment.org/"/></favorite></favfolder><favfolder created="2000-11-17T14:39" title="distro" id="(R6t91|e}fN^x}^.*aRN"><favorite lv="2000-11-17T14:31" vc="1" id="(R6t8+Y+[2\>5Y.wYNlw"><title>SuSE</title><href>http://www.suse.com/</href><created>2000-11-17T14:31</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.suse.com/"/></favorite><favorite lv="2000-11-17T14:31" vc="1" id="(R6t8*[hk.@U7hp9,_il"><title>Redhat</title><href>http://www.redhat.com/</href><created>2000-11-17T14:31</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.redhat.com/"/></favorite><favorite lv="2000-11-17T14:31" vc="1" id="(R6t8(Syiv_v_g@i:4^Y"><title>Linux-Mandrake</title><href>http://www.linux-mandrake.com/en/</href><created>2000-11-17T14:31</created><p ropbag sect="DEFAULT" prop="BASEURL" val="http://www.linux-mandrake.com/en/"/></favorite><favorite lv="2000-11-17T17:53" vc="2" id="(R6t7}Cw`T0dzve+hAR<"><title>Slackware</title><href>http://www.slackware.com/</href><created>2000-11-17T14:31</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.slackware.com/"/></favorite><favorite lv="2000-11-17T14:35" vc="1" id="(R6t8[k,1*<i_UXN)PAs"><title>Yellow Dog</title><href>http://www.yellowdoglinux.com/</href><created>2000-11-17T14:35</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.yellowdoglinux.com/"/></favorite><favorite lv="2000-11-17T14:35" vc="1" id="(R6t8Z@>4XcWQ4UCjq3:"><title>Debian GNU/Linux</title><href>http://www.debian.org/</href><created>2000-11-17T14:35</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.debian.org/"/></favorite><favorite lv="2000-11-17T14:36" vc="1" id="(R6t8\kQfH,q9aUi{Vcp"><title>Caldera</title><href>http://www.caldera.com/</href><created>2000-11-17T14:36</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.caldera.com/"/></favorite></favfolder></favfolder><favfolder created="2000-11-16T13:12" title="satire" id="(R6qxBrd1r/LjW07AfF]"><favorite lv="2000-11-16T13:13" vc="2" id="(R6qx8_GZ8Qo`kdg:68v"><title>The Onion | America's Finest News Source</title><href>http://www.onion.com/</href><created>2000-11-16T13:11</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.onion.com/"/><propbag sect="DOC#8#9" prop="BASEURL" val="http://www.onion.com/onion3641/index.html"/><propbag sect="DOC#8#9" prop="ORIGURL" val="onion3641/index.html"/></favorite><favorite lv="2000-11-17T17:51" vc="2" id="(R6qxAVdy2m.JO;Cvb)R"><title>BBspot - Hooked on Satire</title><href>http://www.bbspot.com/</href><created>2000-11-16T13:12</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.bbspot.com/"/></favorite><favorite lv="2000-11-16T13:11" vc="1" id="(R6qx http://www.linuxnewbie.org/ubb/biggrin.gif:`0G/(9ZK[liQ"><title>SatireWire | dot.com.edy</title><href>http://www.satirewire.com/</href><created>2000-11-16T13:11</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.satirewire.com/"/></favorite></favfolder><favfolder created="2000-11-15T19:21" title="comics" id="(R6pEa>c.h_.nmHCQ;zw"><favorite lv="2000-11-16T12:49" vc="2" id="(R6pE[<-F`CYI_\@:9ZV"><title>User Friendly the Comic Strip - The Daily Static</title><href>http://www.userfriendly.org/static/</href><created>2000-11-15T19:20</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.userfriendly.org/static/"/></favorite><favorite lv="2000-11-16T12:49" vc="2" id="(R6pEXyY.8hpH:;JINEG"><title>Dilbert Zone - The Official Dilbert Website by Scott Adams - Dilbert, Dogbert and Coworkers!</title><href>http://www.dilbert.com/</href><created>2000-11-15T19:20</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.dilbert.com/"/><propbag sect="DOC#21" prop="BASEURL" val="http://ad.doubleclick.net/adi/www.dilbertss.com/ros;sz=1x1;ord='%20+%20same%20+%20'?"/><propbag sect="DOC#21" prop="ORIGURL" val="http://ad.doubleclick.net/adi/www.dilbertss.com/ros;sz=1x1;ord=' + same + '?"/><propbag sect="DOC#133" prop="BASEURL" val="http://ad.doubleclick.net/adi/www.dilbert.com/homepage/"/><propbag sect="DOC#133" prop="ORIGURL" val="http://ad.doubleclick.net/adi/www.dilbert.com/homepage/"/></favorite><favorite lv="2000-11-15T19:20" vc="1" id="(R6pEWQ\p0aUhkr>lCej"><title>General Protection Fault--The Comic Strip</title><href>http://www.gpf-comics.com/</href><created>2000-11-15T19:20</created><propbag sect="DEFAULT" prop="BASEURL" val="http://www.gpf-comics.com/"/><propbag sect="DOC#88" prop="BASEURL" val="http://ad2.doubleclick.net/adi/www.keenspot.com/generalprotectionfault;sz=468x60;ord=5207056667232 81340"/><propbag sect="DOC#88" prop="ORIGURL" val="http://ad2.doubleclick.net/adi/www.keenspot.com/generalprotectionfault;sz=468x60;ord=5207056667232 81340"/><propbag sect="DOC#88#7" prop="BASEURL" val="http://ad-adex3.flycast.com/server/iframe/Superosity/SonarDefault/;referrer=ad2.doubleclick.net%2fadi%2fwww.keenspot .com%2fgeneralprotectionfault%3bsz%3d468x60%3bord% 3d5207056 66723281340;/6015575"/><propbag sect="DOC#88#7" prop="ORIGURL" val="http://ad-adex3.flycast.com/server/iframe/Superosity/SonarDefault/;referrer=ad2.doubleclick.net%2fadi%2fwww.keenspot .com%2fgeneralprotectionfault%3bsz%3d468x60%3bord% 3d5207056 66723281340;/6015575"/><propbag sect="DOC#251" prop="BASEURL" val="http://ad2.doubleclick.net/adi/www.keenspot.com/generalprotectionfault;sz=468x60;ord=5207056667232 81340"/><propbag sect="DOC#251" prop="ORIGURL" val="http://ad2.doubleclick.net/adi/www.keenspot.com/generalprotectionfault;sz=468x60;ord=5207056667232 81340"/><propbag sect="DOC#251#7" prop="BASEURL" val="http://ad-adex3.flycast.com/server/iframe/Superosity/SonarDefault/;referrer=ad2.doubleclick.net%2fadi%2fwww.keenspot .com%2fgeneralprotectionfault%3bsz%3d468x60%3bord% 3d5207056 66723281340;/6015575"/><propbag sect="DOC#251#7" prop="ORIGURL" val="http://ad-adex3.flycast.com/server/iframe/Superosity/SonarDefault/;referrer=ad2.doubleclick.net%2fadi%2fwww.keenspot .com%2fgeneralprotectionfault%3bsz%3d468x60%3bord% 3d5207056 66723281340;/6015575"/></favorite></favfolder></favorites>

Strike
11-17-2000, 04:40 PM
What if I wrote a vim script for it? I don't think it'd be all that hard. I mean, would you want it to look like this:


Folder: "programming"
* Planet Source Code {http://www.planet-source-code.com/)
* Visual Basic World (http://www.vbworld.com)
...
(and so on)


That kind of a formatting? I mean, could we strip out all the worthless crap like the "id" and "vc" fields and such?

ille_pugil42
11-17-2000, 04:43 PM
well, I want to import *back* into my MSN Explorer at work, since I have to use MSN explorer (see below)
http://www.linuxnewbie.org/ubb/Forum6/HTML/002291.html

Mikenell
11-17-2000, 04:59 PM
*This could be nothing to do with what you want because I didn't totally understand what you mean so if its not then just ignore me but if you right click in the favourites list and choose Sort By Name then it should put them in alphabetical order.

YaRness
11-17-2000, 05:18 PM
well, this is a start. it parses out and pairs up titles and web pages. i can't quite handle the newlines correctly though. if someone wants to build on it, feel free.


#!/usr/bin/perl -w

open (INFILE, $ARGV[0]) | | die;

$/="created";
while (<INFILE> )
{
if (/<title>([^<>\/]+)<\/title><href>(http:.*\/)+<\/href>/) {
$output = "$1, $2";
$output =~ tr/\n//;
print "$output\n";
}
}

that prints this:


Planet SourceCode, http://www.planet-source-code.com/
Visual Basic
World, http://www.vbworld.com/
[fm], http://freshmeat.net/
linuxmail.org, http://www.linuxmail.org/
LNO, http://www.linuxnewbie.org/
Kde, http://www.kde.org/
GNOME, http://www.gnome.org/
icewm, http://icewm.sourceforge.net/
Sawfish, http://www.sawfish.org/
Blackbox, http://blackbox.alug.org/
AfterStep, http://www.afterstep.org/
Enlightenment, http://www.enlightenment.org/
SuSE, http://www.suse.com/
Redhat, http://www.redhat.com/
Linux-Mandrake, http://www.linux-mandrake.com/en/
Slackware, http://www.slackware.com/
Yellow
Dog, http://www.yellowdoglinux.com/
Caldera, http://www.caldera.com/
The Onion | America's Finest News
Source, http://www.onion.com/
BBspot - Hooked on Satire, http://www.bbspot.com/
SatireWire |
dot.com.edy, http://www.satirewire.com/
User Friendly the Comic Strip - The Daily Static, http://www.userfriendly.org/static/
Dilbert Zone - The Official
Dilbert Website by Scott Adams - Dilbert, Dogbert and Coworkers!, http://www.dilbert.com/
General Protection Fault--The Comic
Strip, http://www.gpf-comics.com/



------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/
------------------

ille_pugil42
11-17-2000, 05:23 PM
cool! That's good, now can we just rearrange those and write the file so they are in alphabetical order (with the folders?).


Mikenell: This is the _NEW_ msn explorer, and there is frankly no option anywhere close to that. Trust me, I support it. http://www.linuxnewbie.org/ubb/frown.gif Thanks anyway.

YaRness
11-17-2000, 05:24 PM
ok i fixed it. one of the things i added to the tr// worked. *shrug*


#!/usr/bin/perl -w

open (INFILE, $ARGV[0]) | | die;

$/="created";
while (<INFILE> )
{
if (/<title>([^<>\/]+)<\/title><href>(http:.*\/)+<\/href>/) {
# $1 =~ tr/\n//;
# $2 =~ tr/\n//;
$output = "$1, $2";
$output =~ tr/\n\f\r//d;
print "$output\n";
}
}


the output is the same as above without the extra newlines

------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/
------------------

YaRness
11-17-2000, 05:27 PM
Originally posted by ille_pugil42:
cool! That's good, now can we just rearrange those and write the file so they are in alphabetical order (with the folders?).


Mikenell: This is the _NEW_ msn explorer, and there is frankly no option anywhere close to that. Trust me, I support it. http://www.linuxnewbie.org/ubb/frown.gif Thanks anyway.

that's shouldn't be too hard to do. but i have like, a life and stuff http://www.linuxnewbie.org/ubb/biggrin.gif if i get bored this weekend i'll look at it. i'm about to bail from work though, and, it's like, friday man.

all the code i posted is open to assimilation if anyone else wants to use it though.

------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/
------------------

ille_pugil42
11-20-2000, 08:56 AM
Now this is perl right? This gives me a great start, will look into adding to it tonight myself (and probably messing something up). Any ideas on how to see XML in linux?

klamath
11-20-2000, 10:31 AM
The 'proper' way would be to use XML::Parser and process the XML properly.

------------------
- Klamath
Get my GnuPG Key Here (http://klamath.dyndns.org/mykey.asc)
Looking for an open source project to contribute to? Check out the BBB (http://bbb.sourceforge.net)