Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
maybe someting ugly as (modified the data to get rid of the --boundary thing):
#!/usr/bin/perl use strict; use warnings; use XML::Twig; $|++; open my $fh,'<','xmlstream.xml' or die; while (<DATA>) { chomp; if ($_ =~/Content-Length: (\d+)/){ my $len = $1; my $xml; my $read = read (DATA,$xml,$len,0); print "read: tried $len got $read: [$xml]\n"; my $t= XML::Twig->new( pretty_print => 'indented', twig_handlers => { 'ipAddress'=>sub{print "\t\tIP ADDRESS:\t",$ +_[1]->text,"\n"; } } ); $t->parse($xml); } } __DATA__ Content-Type: application/xml; charset="UTF-8" Content-Length: 478 <EventNotificationAlert version="1.0" xmlns=" +ver10/XMLSchema"> <ipAddress></ipAddress> <portNo>80</portNo> <protocol>HTTP</protocol> <macAddress>c4:2f:90:00:00:00</macAddress> <channelID>1</channelID> <dateTime>2015-06-24T19:37:22--8:00</dateTime> <activePostCount>0</activePostCount> <eventType>videoloss</eventType> <eventState>inactive</eventState> <eventDescription>videoloss alarm</eventDescription> </EventNotificationAlert> Content-Type: application/xml; charset="UTF-8" Content-Length: 514 <EventNotificationAlert version="1.0" xmlns=" +ver10/XMLSchema"> <ipAddress></ipAddress> <portNo>80</portNo> <protocol>HTTP</protocol> <macAddress>c4:2f:90:00:00:00</macAddress> <channelID>1</channelID> <dateTime>2015-06-24T19:37:22--8:00</dateTime> <activePostCount>1</activePostCount> <eventType>VMD</eventType> <eventState>active</eventState> <eventDescription>Motion alarm</eventDescription> <DetectionRegionList> </DetectionRegionList> </EventNotificationAlert>


There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re^4: XML Parsing from URL - XML::Twig and infinite stream by Discipulus
in thread SOLVED: XML Parsing from URL by jshank

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2023-12-04 23:10 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (25 votes). Check out past polls.