Hello world,
I used XML::Simple to parse my XML-File. The XML-File is not in good syntax. But I have no possibilities to correct the syntax at the moment. Here is an example of the XML-File:
As you can see, the value host2 is not good defined.
When I parse such a kind of xml, XML::Simple returns me an array of the network_objects_object. Over this array I can access the different attributes. But I could not find the value host2 or host3.
Is there a possibility to use XML::Simple the right way to get this information. Or is there a XML-Module which can handle these kind of mad XML-Files?
In the first step, I only use the following code:
As you can see, I also tried to use the option KeepRoot without any success.
Thx.
ciao
mr_drlove
I used XML::Simple to parse my XML-File. The XML-File is not in good syntax. But I have no possibilities to correct the syntax at the moment. Here is an example of the XML-File:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<hosts>
<network_objects_object>host2<DAG>false</DAG>
<color><![CDATA[blue]]></color>
<comments><![CDATA[This is a sample host2]]></comments>
</network_objects_object>
<network_objects_object>host3<DAG>false</DAG>
<color><![CDATA[blue]]></color>
<comments><![CDATA[This is a sample host3]]></comments>
</network_objects_object>
</hosts>
As you can see, the value host2 is not good defined.
When I parse such a kind of xml, XML::Simple returns me an array of the network_objects_object. Over this array I can access the different attributes. But I could not find the value host2 or host3.
Is there a possibility to use XML::Simple the right way to get this information. Or is there a XML-Module which can handle these kind of mad XML-Files?
In the first step, I only use the following code:
Code:
#!/usr/bin/perl
use XML::Simple;
print "START\n";
my $xs = XML::Simple->new();
#my $ref = $xs->XMLin('../sample/sample2.xml');
my $ref = $xs->XMLin('../sample/sample2.xml',KeepRoot =>1);
use Data::Dumper;
print Dumper($ref);
Thx.
ciao
mr_drlove