Click here to get back home

Will XML::Simple work with keys, strings, integers, and dates?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Will XML::Simple work with keys, strings, integers, and dates? Wes Barris 03-21-2005
Posted by Wes Barris on March 21, 2005, 10:43 am
Please log in for more thread options


Hi,

I am trying to use XML::Simple to parse an xml file. However, the xml file
that I am trying to parse is not in the same format as any of the XML::Simple
examples that I have seen. In all of the examples I have seen, the xml tags
are specific to their contents. In my xml file, the tag names are generic.
Here is a short sample of the xml that I am trying to parse:

<dict>
<key>35</key>
<dict>
<key>Track ID</key><integer>35</integer>
<key>Name</key><string>Earache My Eye (Full Version)</string>
<key>Artist</key><string>Alice Bowie</string>
<key>Genre</key><string>Specialty Rock</string>
<key>Kind</key><string>MPEG audio file</string>
<key>Size</key><integer>6459519</integer>
<key>Total Time</key><integer>322951</integer>
<key>Date Modified</key><date>2005-02-16T12:03:00Z</date>
<key>Date Added</key><date>2005-02-16T11:59:14Z</date>
<key>Bit Rate</key><integer>160</integer>
<key>Sample Rate</key><integer>44100</integer>
<key>Track Type</key><string>File</string>

<key>Location</key><string>file://localhost/M:/1970s/Alice%20Bowie%20-%20Earache%20My%20Eye.mp3/</string>
<key>File Folder Count</key><integer>2</integer>
<key>Library Folder Count</key><integer>1</integer>
</dict>
<key>36</key>
<dict>
<key>Track ID</key><integer>36</integer>
<key>Name</key><string>Earache My Eye</string>
<key>Artist</key><string>Cheech &#38; Chong</string>
<key>Genre</key><string>Specialty Rock</string>
<key>Kind</key><string>MPEG audio file</string>
<key>Size</key><integer>1875968</integer>
<key>Total Time</key><integer>156204</integer>
<key>Date Modified</key><date>2005-02-16T12:03:21Z</date>
<key>Date Added</key><date>2005-02-16T11:59:15Z</date>
<key>Bit Rate</key><integer>96</integer>
<key>Sample Rate</key><integer>32000</integer>
<key>Track Type</key><string>File</string>

<key>Location</key><string>file://localhost/M:/1970s/Cheech%20&#38;%20Chong%20-%20Earache%20My%20Eye.mp3/</string>
<key>File Folder Count</key><integer>2</integer>
<key>Library Folder Count</key><integer>1</integer>
</dict>

I would like to be able to extract things like the "Name", "Artist", and
"Location" but I don't understand how to associate one of the elements of
the key array with one of the elements of the resulting string array.
--
Wes Barris


Similar ThreadsPosted
Extracting strings delimited by other strings May 7, 2005, 11:54 am
Converting dates March 30, 2005, 5:22 am
DBD::SQLite and big integers December 13, 2004, 1:02 am
strings and numbers July 30, 2005, 2:28 am
strings and numbers July 30, 2005, 2:27 am
Zertifikate/Keys September 17, 2007, 4:16 am
perl : Importing registry keys February 3, 2005, 11:34 am
Curses::UI::Widget - binding function keys July 18, 2006, 1:53 am
Return keys from $db->DataHash directly into an array September 16, 2007, 11:56 am
$db->DataHash does not return keys/fields in same order as they appear in database September 16, 2007, 11:59 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap