ok here is another idea I had:

# use XML::Dumper; open (XMLINPUT, "e:/topo.xml") or (print "Die XML Datei konnte nicht geöffnet werden!!\n". "Bitte Pfad und Dateiname mit Slashs angeben!!". "\nz.B. c:/data1.xml\n" and open (MACERROR, ">XMLError.err") and print MACERROR "Die XML Datei konnte nicht geöffnet werden!!\n +". "Bitte Pfad und Dateiname mit Slashs angeben!!". "\nz.B. c:/data1.xml\n" and close MACERROR and exit); # Zeiger erzeugen $zeiger_xml = new XML::Dumper->xml2pl(join("",<XMLINPUT>)); $zeiger_data = \@{$zeiger_xml->{'Data'}}; close XMLINPUT; open (CACHENEU, ">ips2.txt"); close CACHENEU; foreach $z_device (@{$zeiger_xml->{'Device'}}) { #if ( $z_device->{'SystemDescription'} =~ m/Version 12.0 +\(5\)/ #and $z_device->{'SystemDescription'} =~ m/C2900/ #and $z_device->{'SystemDescription'} !~ m/WS/) #{ open (CACHENEU, ">>ips2.txt"); foreach $z_add (@{$z_device->{'DeviceName'}}) { %PortHash = ( $z_device->{'DeviceName'} => $z_ip->{'IPAddr +ess'} ); printf CACHENEU ("%s\t\t%s\n",%PortHash); } close CACHENEU; #} } print "\nfertig Portliste erstellen!!\n" ;


and this is the File I have to read from:

<?xml version="1.0" encoding="UTF-8" ?> - <CMData> <CMServer>S03</CMServer> <CreatedAt>Tue Aug 24 09:09:41 GMT+02:00 2004</CreatedAt> <SchemaVersion>1.0</SchemaVersion> <Heading>Topology Data</Heading> - <Layer2Details> - <Device> <DeviceName>LWL-H91-CW-4-5-4</DeviceName> <IPAddress>148.192.59.254</IPAddress> <DeviceState>Reachable</DeviceState> <DeviceType>C2950G-24</DeviceType> - <Neighbors> - <Neighbor> <NeighborIPAddress>148.192.22.22</NeighborIPAddress> <NeighborDeviceType>C6506</NeighborDeviceType> <Link>Point to Point link</Link> <LocalPort>Gi0/2</LocalPort> <RemotePort>3/3</RemotePort> </Neighbor>


Any idea on where I am mistaking??

In reply to Re^2: Extracting tagged data from a XML file by theroninwins
in thread Extracting tagged data from a XML file by theroninwins

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.