SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help parsing XML using Perl

    My hands are full and I am in need of quick help writing a Perl script to parse XML and convert the contents to an HTML page. Pls PM me so I can provide all the details.

    Thanks.

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2009
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're better off just posting the details here. That is.. if you want quick help. Or any help at all for that matter.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, below is a snippet of the XML. I need a script (not a how-to guide) that will take the contents of that XML and generate an HTML code to display it. The part about generating the HTML is easy enough. It's the reading of the XML and picking out the elements that I need help with.

    TIA

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
      <channel>
        <title>Title Goes Here....</title>
        <description>This feed contains data from somewhere.com</description>
        <link>http://www.somewhere.com/</link>
        <image>
          <title>somewhere.com</title>
          <url>http://somewhere.com/images/logo.jpg</url>
          <link>http://www.somewhere.com/</link>
          <description>logo</description>
          <width>120</width>
          <height>120</height>
        </image>
        <copyright>somewhere.com</copyright>
        <lastBuildDate>Mon, 14 Dec 2009 04:51:33 GMT</lastBuildDate>
        <docs>http://backend.userland.com/rss</docs>
        <generator>somewhere.com</generator>
        <item>
          <id>1234567890</id>
          <title>Item Title Goes Here</title>
          <description>Description Goes Here</description>
          <link>http://somewhere.com/some-page.html</link>
          <enclosure url="http://www.somewhere.com/video/1234567890" duration="122" type="application/x-shockwave-flash" />
          <media:content url="http://somewhere.com/1234567890/1234567890.flv" type="video/x-flv" expression="sample" duration="122" bitrate="600" lang="eng" />
          <media:title type="plain">Media title goes here</media:title>
          <media:description type="html">Media description goes here</media:description>
          <media:thumbnail url="http://somewhere.com/1234567890/thu_1234567890.jpg" width="75" height="75" time="00:00:50" />
          <media:category label="Art/Crafts">Art/Crafts</media:category>
          <media:rating>General</media:rating>
          <media:keywords>List of keywords go here, more keywords, still more keywprds</media:keywords>
          <media:player url="http://www.somewhere.com/video/1234567890"><![CDATA[<div style='text-align:center'><object width='480' height='401' id='MediaPlayer' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'><param name='allowfullscreen' value='true'/><param name='allowScriptAccess' value='always'/><param name='movie' value='http://www.somewhere.com/Embeded/1234567890/'/><embed name='MediaPlayer' src='http://www.somewhere.com/Embeded/1234567890/' type='application/x-shockwave-flash' width='480' height='401' allowfullscreen='true' allowScriptAccess='always'></embed></object><br/><a href='http://www.somewhere.com/Video/1234567890' style='font-family: Verdana;font-size: 10px;' target='_blank'>Title Goes Here</a></div>]]></media:player>
          <pubDate>Mon, 14 Dec 2009 04:51:33 GMT</pubDate>
          <image>
            <title>Title Goes Here</title>
            <url>http://somewhere.com/1234567890/thu_1234567890</url>
            <link>http://www.somewhere.com/video/1234567890</link>
            <width>150</width>
            <height>150</height>
          </image>
        </item>
      </channel>
    </rss>

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is a perl package XML::Simple which you can give an XML data stream (by means of a file name if you want) and it will return a HASH.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •