ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
July 17th, 2024 | 10:00am-11:55am SGT (UTC+8) | Online

Ethereal-dev: Re: [Ethereal-dev] RFC: Print as XML

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: John McDermott <jjm@xxxxxxxxxx>
Date: Mon, 22 Sep 2003 10:17:04 -0600


Gilbert Ramirez wrote:
I'm adding the ability to [t]ethereal to print a capture file as XML. I
need this so I can write a Python program to reconstruct data from a
capture file and produce a nice report. Someday we'll embed Python in
Ethereal, but until then, this feature should help me and others wishing
to do similar things.

I'm not an XML expert. I see two styles of printing as XML. Either by
making the field names and values attributes of "node" elements:

Here is a third option with perl code to access it. Hopefully we'll embed perl in Ethereal or at least make it an option :-).

The XML is after the __DATA__. Note the simplification compared to Gilbert's second option.

use strict;
use XML::Simple;
use Data::Dumper;
use IO::Handle;

my $io = new IO::Handle;
my $packet = XMLin($io->fdopen(fileno(DATA),"r"));
print Dumper($packet);

__DATA__
<ethereal-packets>
  <frame>
    <marked>0</marked>
    <time>Sep 17, 2003 10:12:45.069203000</time>
    <time_delta>0.035904000</time_delta>
    <time_relative>38.980675000</time_relative>
    <number>253</number>
    <pkt_len>1514</pkt_len>
    <cap_len>1514</cap_len>
    <file_off>70170</file_off>
  </frame>
</ethereal-packets>

--john

--
John McDermott
Writer, Educator, Consultant
jjm@xxxxxxxxxx		http://www.jkintl.com
V +1 505/377-6293 F +1 505/377-6313