XML::CAP - parse or generate the XML Common Alerting Protocol (CAP)
Version 0.02
XML::CAP parses and generates XML Common Alerting Protocol (CAP).
More information about CAP can be found at http://www.incident.com/cookbook/
Each XML CAP structure has an "alert" section. Each alert may contain zero (usually one) or more "info" sections. Each info section may contain zero or more "resource" and/or "area" sections. Each area section may contain zero or more "geocode" sections. All of these sections are represented by subclasses of XML::CAP.
XML::CAP uses XML::LibXML. There are accessor functions for every element. But using the elem() method, there is also direct access to the corresponding LibXML node.
Code sample:
use XML::CAP; use XML::CAP::Parser; my $parser = XML::CAP::Parser->new(); $parser->parse_file( "cap-file.xml" ); my $alert; eval_wrapper ( sub { $alert = $parser->alert }); @alert_nodes = $alert->elem->childnodes; # access to XML::libXML data $identifier = $alert->identifier; $sender = $alert->sender; $sent = $alert->sent; $status = $alert->status; $msgType = $alert->msgType; $source = $alert->source; $scope = $alert->scope; $restriction = $alert->restriction; $addresses = $alert->addresses; $code = $alert->code; $note = $alert->note; $references = $alert->references; $incidents = $alert->incidents; my @infos = $alert->infos; @info_nodes = $infos[0]->elem->childnodes; # access LibXML data my $info = $infos[0]; $language = $info->language; $category = $info->category; $event = $info->event; $responseType = $info->responseType; $urgency = $info->urgency; $severity = $info->severity; $certainty = $info->certainty; $audience = $info->audience; $eventCode = $info->eventCode; $effective = $info->effective; $onset = $info->onset; $expires = $info->expires; $senderName = $info->senderName; $headline = $info->headline; $description = $info->description; $instruction = $info->instruction; $web = $info->web; $contact = $info->contact; $parameter = $info->parameter; my @resources = $info->resources; @resource_nodes = $resources[0]->elem->childnodes; # access LibXML data my $resource = $resources[0]; $resourceDesc = $resource->resourceDesc; $mimeType = $resource->mimeType; $size = $resource->size; $uri = $resource->uri; $derefUri = $resource->derefUri; $digest = $resource->digest; my @areas = $info->areas; @area_nodes = $areas[0]->elem->childnodes; # access LibXML data my $area = $areas[0]; $areaDesc = $area->areaDesc; $polygon = $area->polygon; $circle = $area->circle; $altitude = $area->altitude; my @geocodes = $area->geocodes; @geocode_nodes = $geocodes[0]->elem->childnodes; # access LibXML data my $geocode = $geocodes[0]; $valueName = $geocode->valueName; $value = $geocode->value;
Ian Kluft, <ikluft at cpan.org>
<ikluft at cpan.org>
Please report any bugs or feature requests to bug-xml-cap at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-CAP. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-xml-cap at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc XML::CAP
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=XML-CAP
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/XML-CAP
CPAN Ratings
http://cpanratings.perl.org/d/XML-CAP
Search CPAN
http://search.cpan.org/dist/XML-CAP/
The initial version was derived from XML::Atom by Benjamin Trott and Tatsuhiko Miyagawa.
Copyright 2009 Ian Kluft, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install XML::CAP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::CAP
CPAN shell
perl -MCPAN -e shell install XML::CAP
For more information on module installation, please visit the detailed CPAN module installation guide.