Thread XML: Zahlen anhand von Keywords finden (19 answers)
Opened by cohama at 2013-03-28 13:16

cohama
 2013-04-05 09:19
#166892 #166892
User since
2011-08-16
102 articles
BenutzerIn

user image
Hallo zusammen,

es sieht so aus, wenn ich das Skript von pg nutze funktioniert es.
Wenn ich mit meinem Script versuche, funktioniert es nicht.
Hier mein Script:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl -w
# Version 0.3
# Date Apr 2013
########################################
# Modules
use strict; # parameter Definition before use them
use XML::LibXML; # Libary for XML
use IO::Socket::SSL; # TCP/IP sockets
#######################################
# Paramet Definition
my $host = '192.168.2.101'; # Test OMM
my $port = 12622; # OpenMobility-Manager-Port
my $seqid = "4711"; # nice to have
my $uname = "operator";
my $pw = "LoginPW";
my $protoVer = 41; # OM AXI Protocol Version -> unimportant
my $timer = 1;
my ($basicInfo,$OM_AXI_Input,$UserNotes,$myResponse,$Users); # Basic information -> Standard Response
my ($RecAmount,$firstPPN);
my @Values;
my $socket = IO::Socket::SSL->new(PeerAddr=>$host,PeerPort=>$port,Timeout=>$timer);
# XML Parameter
my $myObj = XML::LibXML->new;
my ($preLine,$XMLin,$doc,$root,$PPN,$field);
my ($child,$at,$na,$va);
my (@kids,@atts);
###########################
# main programm
system("clear");
##################################
# OMM Axi
$UserNotes = qq{<GetPPUser uid="2"/>\0};
$socket -> print(qq{<Open seq="$seqid" protocolVersion=$protoVer username="$uname" password="$pw"/>\0}); # Send Authentication
$basicInfo = $socket->readline();
$socket -> print($UserNotes);
$Users = $socket->readline();
############
# XML Parsing
##################
$preLine = '<?xml version="1.0" encoding="UTF-8"?>';
$XMLin = $preLine.$Users;
print "$XMLin \n";
$doc = $myObj->parse_string($XMLin); # Search through the XMl-Stuff
$root = $doc->documentElement;
($PPN) = $doc->findnodes("user"); # Find the keyword

for $field ( qw{uid ppn ethAddr hwType}) {
say $PPN->getAttribute($field)
}


Hier nochmal die erweiterte Antwort vom Server:

Code: (dl )
<?xml version="1.0" encoding="UTF-8"?><GetPPUserResp><user uid="2" relType="Unbound" ppn="0" name="Albert Einstein" num="3461" hierarchy1="Physics" hierarchy2="Dr h.c." addId="" sipAuthId="3461" sipPw="M0ziPLBb9ntxkx68hJ8920lcarx0x0SX5Lvcs5Pzi4TQeThP/vKsKEx1lLK9tiKc3FxREhGRpkUUIjY+FkmRag==" sosNum="" manDownNum="" voiceboxNum="" pin="ZkDJaRCnZgC6IxEaB4T2hm6cOrbwgfErC8DACJt5IVFqcfexe8ilupZYYg8QdBQMl6DHVEWlowooZSGYrTbFFw==" lang="English" forwardState="Off" forwardDest="" forwardTime="0" holdRingBackTime="3" callWaitingDisabled="0" trackingActive="0" locRight="0" locatable="1" msgRight="0" sendVcardRight="0" recvVcardRight="0" keepLocalPB="0" vip="0" external="0" BTlocatable="1" BTsensitivity="high" conferenceServerType="Global" conferenceServerURI="" monitoringMode="Off" HAS="Unknown" HSS="Unknown" HRS="Unknown" HCS="Unknown" SRS="Unknown" SCS="Unknown" CDS="Unknown" HBS="Unknown" BTS="Unknown" SWS="Unknown" CUS="Unknown" /></GetPPUserResp>


Ich bin sicher, dass mehrere Augen den Grund daf├╝r finden. ;-)

View full thread XML: Zahlen anhand von Keywords finden