Parsejar fitxers XML

De Wikijoan
Dreceres ràpides: navegació, cerca

llibreria de C++ per parsejar XML: tinyxml

descomprimeixo i

$ sudo make

o bé compilem directament:

$ g++ -o xmltest tinyxml.cpp tinyxmlparser.cpp xmltest.cpp tinyxmlerror.cpp tinystr.cpp
$ ./xmltest

Exemple pràctic. ROMs d'AdvanceMAME

El format del fitxer MAME 106u13.dat és:

<?xml version="1.0"?>
<!DOCTYPE datafile PUBLIC "-//Logiqx//DTD ROM Management Datafile//EN" "http://www.logiqx.com/Dats/datafile.dtd">

<datafile>
	<header>
		<name>MAME</name>
		<description>MAME 0.106u13</description>
		<category>Emulation</category>
		<version>0.106u13</version>
		<date>-not specified-</date>
		<author>AntoPISA</author>
		<email>progettosnaps@gmail.com</email>
		<homepage>http://www.progettosnaps.net/</homepage>
		<url>-not specified-</url>
		<comment>-not specified-</comment>
		<clrmamepro/>
	</header>
	<game name="005" sourcefile="segar.c">
		<description>005</description>
		<year>1981</year>
		<manufacturer>Sega</manufacturer>
		<rom name="1346b.u25" size="2048" crc="8e68533e" sha1="a257c556d31691068ed5c991f1fb2b51da4826db"/>
		<rom name="5092.u1" size="2048" crc="29e10a81" sha1="c4b4e6c75bcf276e53f39a456d8d633c83dcf485"/>
		<rom name="5093.u2" size="2048" crc="e1edc3df" sha1="4f593546bbb0f50850dc6286cb514af6831c27a7"/>
		<rom name="5094.u3" size="2048" crc="995773bb" sha1="98dd826527853bc031edfb9a821778cc3e906150"/>
		<rom name="5095.u4" size="2048" crc="f887f575" sha1="de96573a91b60b090b1f441f1410ecad63c9467c"/>
		<rom name="5096.u5" size="2048" crc="5545241e" sha1="ee504ccaab469100137717341a1b461175ff792d"/>
		<rom name="5097.u6" size="2048" crc="428edb54" sha1="4f3df6017068d939014a8f638f28e3228acb7add"/>
		<rom name="5098.u7" size="2048" crc="5bcb9d63" sha1="c0c91bc9f75ad88a6e15c554a980d5c075725fe8"/>
		<rom name="5099.u8" size="2048" crc="0ea24ba3" sha1="95a30c9b63ef1c346df0da71af3fdecd1a75cb8f"/>
		<rom name="5100.u9" size="2048" crc="a79af131" sha1="0ba34130174e196015bc9b9c135c420209dfd524"/>
		<rom name="5101.u10" size="2048" crc="8a1cdae0" sha1="f7c617f9bdb7818e6069a981d0c8820deade134c"/>
		<rom name="5102.u11" size="2048" crc="70826a15" sha1="a86322d0e8a88534e9b78dcde42ae4c441276913"/>
		<rom name="5103.u12" size="2048" crc="7f80c5b0" sha1="00748cd5fc7f75fdca194e748524d406c006296d"/>
		<rom name="5104.u13" size="2048" crc="0140930e" sha1="f8ef894c46d3663bd89d2d817675a67075d3e0d6"/>
		<rom name="5105.u14" size="2048" crc="17807a05" sha1="bd99f5beab0155f6e4d2fab2fa5f4e147c5730d5"/>
		<rom name="5106.u15" size="2048" crc="c7cdfa9d" sha1="6ab7adc60ac7bb53a7175e8de51924008737c9ac"/>
		<rom name="5107.u16" size="2048" crc="95f8a2e6" sha1="89c92e000b3e1630380db779370cf9f5b13e5719"/>
		<rom name="5108.u17" size="2048" crc="d371cacd" sha1="8f2cdcc0b4e3b77e0958d257e37accefc5749cde"/>
		<rom name="5109.u18" size="2048" crc="48a20617" sha1="5b4bc3beda0404ff0a61bb42751b87f71817f363"/>
		<rom name="5110.u19" size="2048" crc="7d26111a" sha1="a6d3652ae606a5b75026e524c9d6aaa78300741e"/>
		<rom name="5111.u20" size="2048" crc="a888e175" sha1="4c0af94441bf51dfc852372a5b90d0830df81363"/>
		<rom name="epr-1286.16" size="2048" crc="fbe0d501" sha1="bfa277689790f835d8a43be4beee0581e1096bcc"/>
	</game>
	<game name="11beat" sourcefile="aleck64.c">
		<description>Eleven Beat</description>
		<year>1998</year>
		<manufacturer>Hudson</manufacturer>
		<rom name="nus-zhaj.u3" size="8388608" crc="95258ba2" sha1="0299b8fb9a8b1b24428d0f340f6bf1cfaf99c672"/>
	</game>
	<game name="1941" sourcefile="cps1.c">
		<description>1941 - Counter Attack (World)</description>
		<year>1990</year>
		<manufacturer>Capcom</manufacturer>
		<rom name="41_09.rom" size="65536" crc="0f9d8527" sha1="3a00dd5772f38081fde11d8d61ba467379e2a636"/>
		<rom name="41_18.rom" size="131072" crc="d1f15aeb" sha1="88089383f2d54fc97026a67f067d448eee5bd0c2"/>
		<rom name="41_19.rom" size="131072" crc="15aec3a6" sha1="8153c03aba005bab62bf0e8b3d15ec1c346326fd"/>
...

A mi només m'interessa el nom de la rom i el nom del joc (descripció).


creat per Joan Quintana Compte, desembre 2011, gener 2016

Eines de l'usuari
Espais de noms
Variants
Accions
Navegació
IES Jaume Balmes
Màquines recreatives
CNC
Informàtica musical
joanillo.org Planet
Eines