#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Question How to Read (String Format) XML file using PERL Script


    i am trying to read .xml file from perl script.
    <ELMNAME><v1>one</v1><v2>two</v2><v3>three</v3><ELMNAME/>
    (eg: `cd /home/modbus; grep "v1" test_30Mar2012.xml`)

    using grep command, which gives xml file contents (except tag Element Name<v1>) as a string without any delimiter.
    (eg: onetwothree)

    help me to fetch the each Element Name and it's value of the xml file separately.

    expected output:
    v1=one
    v2=two
    v3=three
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2009
    Posts
    1,981
    Rep Power
    1225
    Use one of the many XML parsers on cpan.

    Here some of the more common choices.

    http://search.cpan.org/~grantm/XML-S.../XML/Simple.pm
    http://search.cpan.org/~toddr/XML-Parser-2.41/Parser.pm
    http://search.cpan.org/~mirod/XML-Twig-3.39/Twig.pm
    http://search.cpan.org/~shlomif/XML-....96/LibXML.pod

    Comments on this post

    • additude agrees : I agree, use a parser and install it yourself or get your admin to do it for you.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    unable to install CPAN any other option


    Thanks for your Reply.....

    i unable to install CPAN... due to some technical issues..
    Can you tell me any other option to read xml file contents with any delimiter... by using string and file handling classes...
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2009
    Posts
    1,981
    Rep Power
    1225
    What "technical issues" are you referring to?

    Nearly all technical issues that people have claimed boiled down to lack of understanding of how to install modules.

IMN logo majestic logo threadwatch logo seochat tools logo