tinkuPerlMonk2 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Experts,
I need help in extracting some information from xml file using perl.
1) test.xml file
How can I extract hostname1.xxx.com(hostname) and key and env and then put it in one file ( a text file ) using perl scripts
Contents of xml file:
<httpsRoute hostname="abchostname1.xxx.com" port="443" environment="QA +"> <key>6924</key> </httpsRoute> <httpsRoute hostname="hostname3.xxx.com" port="7416" environment="CAT" +> <key>9990068</key> </httpsRoute>
Contents of text file should be:
Route #1 details:
Host=abchostname1.xxx.com
Environment=QA
key=6924
Route #2 details:
Host=hostname3.xxx.com
Environment=CAT
key=9990068
2) I'll have certficate.xml. Using perl how can i extract DN( subjectDN), CN, env and key and put them in a file using PERL Content of xml file:Contents of files should be:<certDet env="QA" subjectDN="/C=US/ST=NC/L=Raleigh/O=DotNet/OU=ETD +;D/CN=test1.xxxx.com"> <key>1234</key> </certDet> <certDet env="dev" subjectDN="/C=US/ST=NC/L=Charlotte/O=xxxxx/OU=W +AS/CN=dev1.xxx.com"> <key>27166</key> </certDet>
Entry1:
DN="/C=US/ST=NC/L=Raleigh/O=DotNet/OU=ET&D/CN=test1.xxxx.com"
CN=test1.xxxx.com
env=QA
key=1234
Entry2:DN="/C=US/ST=NC/L=Charlotte/O=xxxxx/OU=WAS/CN=dev1.xxx.com"
CN=dev1.xxx.com
env=QA
key=1234
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: extracting attribute values which might have multiple occurences from xml file
by derekstucki (Sexton) on Aug 19, 2013 at 21:30 UTC | |
by tinkuPerlMonk2 (Initiate) on Aug 20, 2013 at 13:19 UTC | |
Re: extracting attribute values which might have multiple occurences from xml file
by choroba (Cardinal) on Aug 20, 2013 at 09:28 UTC | |
by tinkuPerlMonk2 (Initiate) on Aug 20, 2013 at 13:17 UTC | |
Re: extracting attribute values which might have multiple occurences from xml file
by poj (Abbot) on Aug 20, 2013 at 09:07 UTC | |
by tinkuPerlMonk2 (Initiate) on Aug 20, 2013 at 13:16 UTC | |
Re: extracting attribute values which might have multiple occurences from xml file
by Anonymous Monk on Aug 20, 2013 at 07:47 UTC |
Back to
Seekers of Perl Wisdom