[linux] Re: perl vraag: tree lezen.

Hugo van der Kooij hvdkooij op vanderkooij.org
Wo Mrt 18 12:47:44 CET 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bas Grolleman wrote:
> Is het niet gewoon een kwestie van
> $VAR1['xml']['island']['id'] = <variabele>
> 
> Hoewel zo te zien 'id' ook een array bevat, dus het kan wel eens
> $VAR1['xml']['island']['id'][2] = <Variable>
> 
> Hoe ziet de XML er uit, dan kan ik het zelf ook een beetje makkelijk testen.

Beide getest maar het pakt nog niet.

         $parser = XML::Parser->new( Style => 'Tree' );
         my $tree = $parser->parsefile( $xmlfile );
         my $islandId = $VAR1['xml']['island']['id'][2];

Met en zonder de [2] aan het einde. En omdat mijn gevoel zegt dat het
$tree moet zijn en niet $VAR1 dat ook nog maar eens getest.

De XML data files (paar duizend!) zien er allemaal uit als volgt:

<?xml version="1.0" encoding="ISO-8859-1" ?>
        <xml>
            <island>
                <id>2972</id>
                <name>Rocios</name>
                <resource>4</resource>
                <wonder>5</wonder>
                <coordinates>
                    <x>30</x>
                    <y>83</y>
                </coordinates>
            </island>
            <source>IkaWorld at IkariamLibrary.com</source>
        </xml>


Hugo.

- --
hvdkooij op vanderkooij.org               http://hugo.vanderkooij.org/
PGP/GPG? Use: http://hugo.vanderkooij.org/0x58F19981.asc

	A: Yes.
	>Q: Are you sure?
	>>A: Because it reverses the logical flow of conversation.
	>>>Q: Why is top posting frowned upon?

Bored? Click on http://spamornot.org/ and rate those images.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAknA314ACgkQBvzDRVjxmYG0ggCfQsZ8sfS95YVYibXxeuUP4203
yJkAn0ohoJ3zPkjsuGQeXKX91dbQ+YVg
=iQbj
-----END PGP SIGNATURE-----



More information about the Linux mailing list