On Mon, 23 Aug 2004 17:02:20 -0400, Thomas, Mark - BLS CTR <[EMAIL PROTECTED]> wrote: > Your code loops around a 'product-announced' element, which doesn't exist in > your file. Does that have something to do with it? > > Since you say you're new to XML parsing, perhaps you'd like to see an > example of an alternate solution. The following is XML::LibXML code, and > XML::Xpath code would be virtually identical. > > use XML::LibXML; > $doc = XML::LibXML->new->parse_file('20040817.xml'); > > foreach my $product ($doc->findnodes('//product-updated')) { > my $name = $product->findvalue('product-name'); > my $upc = $product->findvalue('upc'); > my $msrp = $product->findvalue('msrp'); > #etc > } >
Thanks, I realized that after I had sent that file. The file I wanted to include does have the 'product-announced' elements. The file with both product-updated and product-announced elements is attached. After reading the DTD for the xml I'm receiving it seems that the both element sets 'product-updated' and 'product-announced' can be left out of the document. I'd like a way to check and see which ones are present and if so, process each accordingly, as they have different elements in them. Could I use the "findnodes" subroutine you're using above as a regular expression? Thanks for your help, Kevin -- Kevin Old [EMAIL PROTECTED]
<?xml version="1.0" encoding="UTF-8"?> <products timestamp="08/20/2004 19:00:10"> <products-announced> <product-announced> <title-info> <title-name>Before Sunrise/Before Sunset (2-Pack)</title-name> <studio></studio> <theatrical-release-date></theatrical-release-date> <box-office></box-office> <title-rating></title-rating> <rating-comment></rating-comment> <synopsis></synopsis> <ppv-holdback></ppv-holdback> </title-info> <product-info> <product-name>Before Sunrise/Before Sunset (DVD) (2-Pack) (B2B)</product-name> <promotion-type>New Release</promotion-type> <market>Sell Through</market> <product-type>Giftset</product-type> <announce-date>8/20/04</announce-date> <presell-date>8/27/04</presell-date> <order-date>10/12/04</order-date> <pre-pack-order-date></pre-pack-order-date> <street-date>11/9/04</street-date> <original-rental-street-date></original-rental-street-date> <original-sell-through-street-date></original-sell-through-street-date> <format>DVD</format> <subformat>Multi Disc</subformat> <media-quantity>2</media-quantity> <pack-count>1</pack-count> <upc>012569596559</upc> <catalog-number>59655</catalog-number> <isbn>1-4198-0269-0</isbn> <sound-track-language>English</sound-track-language> <packaging-type></packaging-type> <master-packaging-detail></master-packaging-detail> <run-time></run-time> <dubbed-indicator>No</dubbed-indicator> <units-per-carton></units-per-carton> <brand></brand> <msrp>$35.98</msrp> <map>$24.95</map> <map-expiration-date>12/9/04</map-expiration-date> <marketing-premium></marketing-premium> <special-version></special-version> <closed-captions>Yes</closed-captions> <pack-info count="1">Before Sunrise | DVD | Widescreen & Fullscreen</pack-info> <pack-info count="1">Before Sunset | DVD | Widescreen</pack-info> <thumbnail></thumbnail> </product-info> </product-announced> <product-announced> <title-info> <title-name>Before Sunrise/Before Sunset (2-Pack)</title-name> <studio></studio> <theatrical-release-date></theatrical-release-date> <box-office></box-office> <title-rating></title-rating> <rating-comment></rating-comment> <synopsis></synopsis> <ppv-holdback></ppv-holdback> </title-info> <product-info> <product-name>Before Sunrise/Before Sunset (DVD) (2-Pack) (SxS)</product-name> <promotion-type>New Release</promotion-type> <market>Sell Through</market> <product-type>Giftset</product-type> <announce-date>8/20/04</announce-date> <presell-date>8/27/04</presell-date> <order-date>10/12/04</order-date> <pre-pack-order-date></pre-pack-order-date> <street-date>11/9/04</street-date> <original-rental-street-date></original-rental-street-date> <original-sell-through-street-date></original-sell-through-street-date> <format>DVD</format> <subformat>Multi Disc</subformat> <media-quantity>2</media-quantity> <pack-count>1</pack-count> <upc>012569596566</upc> <catalog-number>59656</catalog-number> <isbn>1-4198-0270-4</isbn> <sound-track-language>English</sound-track-language> <packaging-type></packaging-type> <master-packaging-detail></master-packaging-detail> <run-time></run-time> <dubbed-indicator>No</dubbed-indicator> <units-per-carton></units-per-carton> <brand></brand> <msrp>$35.98</msrp> <map>$24.95</map> <map-expiration-date>12/9/04</map-expiration-date> <marketing-premium></marketing-premium> <special-version></special-version> <closed-captions>Yes</closed-captions> <pack-info count="1">Before Sunrise | DVD | Widescreen & Fullscreen</pack-info> <pack-info count="1">Before Sunset | DVD | Widescreen</pack-info> <thumbnail></thumbnail> </product-info> </product-announced> <product-announced> <title-info> <title-name>Before Sunset</title-name> <studio>Warner Bros.</studio> <theatrical-release-date>7/2/04</theatrical-release-date> <box-office>5000000</box-office> <genre>Romance</genre> <genre>Romantic Comedy</genre> <genre>Drama</genre> <title-rating>R</title-rating> <rating-comment></rating-comment> <synopsis>Nine years ago, two strangers met by chance, spent a night together in Vienna, and parted before sunrise. Now, they're about to cross paths again - in Paris -- where they will get the chance we all wish we had?</synopsis> <director>Richard Linklater</director> <actor>Ethan Hawke</actor> <actor>Julie Delpy</actor> <other-talent type="Exec Producer">John Sloss</other-talent> <other-talent type="Producer">Richard Linklater</other-talent> <other-talent type="Producer">Anne Walker-Mcbay</other-talent> <other-talent type="Score">Accordion Music</other-talent> <other-talent type="Writer">Richard Linklater</other-talent> <other-talent type="Writer">Ethan Hawke</other-talent> <other-talent type="Writer">Julie Delpy</other-talent> <critic-quote>"Candid, funny, deeply moving." Kevin Durban, NEW YORK TIMES</critic-quote> <critic-quote>"American cinema at its finest." Manohla Dargis, LOS ANGELES TIMES</critic-quote> <critic-quote>"****" ENTERTAINMENT WEEKLY, NEW YORK POST, LOS ANGELES DAILY NEWS, SAN FRANCISCO CHRONICLE, CHICAGO TRIBUNE, NEWSDAY, THE BOSTON GLOBE, CHICAGO READER, THE NEW YORK SUN, SEATTLE POST-INTELLIGENCER, THE PHILADELPHIA INQUIRER</critic-quote> <critic-quote>"Two thumbs up." EBERT & ROEPER </critic-quote> <ppv-holdback></ppv-holdback> </title-info> <product-info> <product-name>Before Sunset (DVD) (WS)</product-name> <promotion-type>New Release</promotion-type> <market>Sell Through</market> <product-type>Single</product-type> <announce-date>8/20/04</announce-date> <presell-date>8/27/04</presell-date> <order-date>10/12/04</order-date> <pre-pack-order-date></pre-pack-order-date> <street-date>11/9/04</street-date> <original-rental-street-date></original-rental-street-date> <original-sell-through-street-date></original-sell-through-street-date> <format>DVD</format> <subformat></subformat> <media-quantity>1</media-quantity> <pack-count>1</pack-count> <upc>085393896225</upc> <catalog-number>38962</catalog-number> <isbn>0-7907-9551-5</isbn> <sound-track-language>English</sound-track-language> <packaging-type></packaging-type> <master-packaging-detail></master-packaging-detail> <run-time>80</run-time> <dubbed-indicator>No</dubbed-indicator> <units-per-carton></units-per-carton> <brand></brand> <msrp>$27.95</msrp> <map>$19.95</map> <map-expiration-date></map-expiration-date> <marketing-premium></marketing-premium> <special-version></special-version> <closed-captions>Yes</closed-captions> <subtitles>1 English</subtitles> <subtitles>2 Francais</subtitles> <subtitles>3 Espanol</subtitles> <screen-aspect>Original Aspect Ratio - 1.85</screen-aspect> <screen-aspect>Widescreen [16:9 Transfer]</screen-aspect> <sound-quality>English: Dolby Surround 5.1</sound-quality> <sound-quality>Francais (Quebec): Dolby Surround 5.1</sound-quality> <thumbnail></thumbnail> </product-info> </product-announced> <product-announced> <title-info> <title-name>Carnivale: The Complete First Season</title-name> <studio>HBO</studio> <theatrical-release-date></theatrical-release-date> <box-office></box-office> <genre>Action/Adventure</genre> <genre>Drama</genre> <title-rating>NR</title-rating> <rating-comment></rating-comment> <synopsis>1934. The Dustbowl. The last great age of magic. In a time of titanic sandstorms, vile plagues, drought and pistilence - signs of God's fury and harbingers of the Apocalypse - the final conflict between good and evil is about to begin. The battle will take place in the Heartland of an empire called America. And when it is over, man will forever trade away wonder for reason. A sweeping epic that is both challenging and highly accessible, this one-hour HBO drama series focuses on the primordial conflict of good vs. evil, as played out against a pair of vivid and unusual backdrops: a traveling carnival working the American Dustbowl circuit, and an evangelical ministry in California. </synopsis> <ppv-holdback></ppv-holdback> </title-info> <product-info> <product-name>Carnivale: The Complete First Season (DVD)</product-name> <promotion-type>New Release</promotion-type> <market>Sell Through</market> <product-type>Single</product-type> <announce-date>8/20/04</announce-date> <presell-date>8/27/04</presell-date> <order-date>11/9/04</order-date> <pre-pack-order-date></pre-pack-order-date> <street-date>12/7/04</street-date> <original-rental-street-date></original-rental-street-date> <original-sell-through-street-date></original-sell-through-street-date> <format>DVD</format> <subformat>Multi Disc</subformat> <media-quantity>6</media-quantity> <pack-count>1</pack-count> <upc>026359885723</upc> <catalog-number>98857</catalog-number> <isbn>0-7831-2838-X</isbn> <sound-track-language>English</sound-track-language> <packaging-type>Digi-Pack</packaging-type> <master-packaging-detail></master-packaging-detail> <run-time>720</run-time> <dubbed-indicator>No</dubbed-indicator> <units-per-carton></units-per-carton> <brand></brand> <msrp>$99.98</msrp> <map>$79.99</map> <map-expiration-date></map-expiration-date> <marketing-premium></marketing-premium> <special-version></special-version> <closed-captions>Yes</closed-captions> <subtitles>1 English</subtitles> <subtitles>2 Francais</subtitles> <subtitles>3 Espanol</subtitles> <screen-aspect>Widescreen [16:9 Transfer]</screen-aspect> <sound-quality>Espanol: Dolby Surround Stereo 2.0</sound-quality> <sound-quality>English: Dolby Surround 5.1</sound-quality> <sound-quality>English: Dolby Surround Stereo 2.0</sound-quality> <sound-quality>Francais: Dolby Surround Stereo 2.0</sound-quality> <special-feature name="Audio Commentary">Director Rodrigo Garcia</special-feature> <special-feature name="Featurette">"Making of Carnivale"</special-feature> <special-feature name="Other">Tarot Card Game<br>Museum of TV and Radio Seminar<br>TCA Trailer<br>The Original Pilot Episode titled "Milfay"</special-feature> <thumbnail></thumbnail> </product-info> </product-announced> </products-announced> <products-updated> <product-updated> <product-name>Gilmore Girls: The Complete First Season (DVD) (RTL) (BB)</product-name> <upc>085393981129</upc> <street-date>12/07/2004</street-date> </product-updated> </products-updated> </products>
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>