Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Extracting tagged data from a XML file

by theroninwins (Friar)
on Aug 31, 2004 at 13:26 UTC ( #387181=note: print w/replies, xml ) Need Help??


in reply to Re: Extracting tagged data from a XML file
in thread Extracting tagged data from a XML file

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??

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://387181]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2022-05-29 06:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?