My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Project Information
Members

NAME

Net::DNS::XML - Transforms a Net::DNS::Packet into well formed XML.

SYNOPSIS

    #!/usr/bin/perl
    
    use Net::DNS::Resolver;
    use Net::DNS::XML;

    # Create Net::DNS::Packet object.
    my $resolver = Net::DNS::Resolver->new();
    my $answer = $resolver->query('quarg.com', 'A', 'IN');

    # Create Net::DNS::XML object.
    my $xmlout = Net::DNS::XML->new([<options>]);
    my $xml = $xmlout->XMLout($answer [, <options>]);

QUICK START

A script that takes two arguments, hostname and record type:

    my $resolver = Net::DNS::Resolver->new();
    my $answer = $resolver->query($ARGV[0], $ARGV[1]);

    my $xmlout = Net::DNS::XML->new(KeepRoot => 1);
    my $xml = $xmlout->XMLout($answer);

    print $xml;

Would output the following XML (which has been wrapped in this example to fit on screen:

    <response>
      <packet answerfrom="205.234.103.204" answersize="95">
        <header id="26002" aa="0" ad="0" ancount="1" arcount="1" cd="0" 
                nscount="2" opcode="QUERY" qdcount="1" qr="1" ra="1" 
                rcode="NOERROR" rd="1" tc="0" />
        <questions>
          <question qclass="IN" qname="quarg.com" qtype="A" />
        </questions>
        <answers>
          <answer name="quarg.com" address="208.113.230.163" class="IN" 
                  rdlength="4" ttl="86400" type="A" />
        </answers>
        <authorities>
          <authority name="quarg.com" class="IN" nsdname="ns2.quarg.com" 
                     rdlength="6" ttl="72051" type="NS" />
          <authority name="quarg.com" class="IN" nsdname="ns1.quarg.com" 
                     rdlength="6" ttl="72051" type="NS" />
        </authorities>
        <additionals>
          <additional name="ns1.quarg.com" address="74.200.85.159" class="IN" 
                      rdlength="4" ttl="86400" type="A" />
        </additionals>
      </packet>
    </response>

DESCRIPTION

Keep in mind

CAVEATS

While all Net::DNS::RR objects are able to be parsed into XML using this module, some types are not I

<fully>
parsed. This is primarly because they output binary data. I haven't figured out (honestly I haven't looked at it at all) how to represent binary data in xml. Or if it's even possible. It is my hope that all record types provided by Net::DNS will ultimately be included.

The fully parsable record types:

  • Net::DNS::RR::A
  • Net::DNS::RR::AAAA
  • Net::DNS::RR::AFSDB
  • Net::DNS::RR::CNAME
  • Net::DNS::RR::DNAME
  • Net::DNS::RR::HINFO
  • Net::DNS::RR::IPSECKEY
  • Net::DNS::RR::ISDN
  • Net::DNS::RR::LOC
  • Net::DNS::RR::MB
  • Net::DNS::RR::MG
  • Net::DNS::RR::MINFO
  • Net::DNS::RR::MR
  • Net::DNS::RR::MX
  • Net::DNS::RR::NAPTR
  • Net::DNS::RR::NS
  • Net::DNS::RR::NSAP
  • Net::DNS::RR::PTR
  • Net::DNS::RR::PX
  • Net::DNS::RR::RP
  • Net::DNS::RR::RT
  • Net::DNS::RR::SRV
  • Net::DNS::RR::SOA
  • Net::DNS::RR::TXT
  • Net::DNS::RR::TKEY
  • Net::DNS::RR::TSIG
  • Net::DNS::RR::X25

The incomplete record types:

  • Net::DNS::RR::APL
  • Net::DNS::RR::CERT
  • Net::DNS::RR::EID
  • Net::DNS::RR::NIMLOC
  • Net::DNS::RR::NULL
  • Net::DNS::RR::SSHFP

SEE ALSO

Net::DNS, XML::Simple, and our Web site: http://code.google.com/p/perl-net-dns-xml/.

AUTHOR

Michael De Soto, desoto@cpan.org

COPYRIGHT AND LICENSE

Copyright (C) 2008-2009 Michael De Soto. All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Powered by Google Project Hosting