pawank86 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to write the script which will read the value of each tag from xml file. I find some solutions which gives the value of tag passed to it but i m not aware of tag in xml file. So my requirement is like read the value of each tag in xml file. In another solution below, the Dumper is printing tag and Value of xml for refernce passed to it. But i need only values for tags: use XML::Parser; open ($SW,'>out_xml.txt') or die ("died"); my $xmlfile = 'xml\TextRules_Boilerplate.xml'; $parser = new XML::Parser( Style => 'Tree' ); my $tree = $parser->parsefile( $xmlfile ); use Data::Dumper; print $SW Dumper $tree;
  • Comment on How i can read the value of each tag in xml file

Replies are listed 'Best First'.
Re: How i can read the value of each tag in xml file
by marto (Cardinal) on Mar 02, 2010 at 11:57 UTC

      For inline reference, Can i execute two queries connecting to same DB at a time. originally read:

      I have connected to SQL DB and i want to execute two queried at a time. For single query i execute it works fine but when i execute another query it gives error

      "DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver]Conn +ection is busy with result Use of uninitialized value in concatenation (.) or string at Y:\read_m +dt.pl line 26, <> line 1."

      Please let me know if i am doing something wrong.

      HTH,

      planetscape
Re: How i can read the value of each tag in xml file
by Corion (Patriarch) on Mar 02, 2010 at 11:57 UTC
Re: How i can read the value of each tag in xml file
by rovf (Priest) on Mar 02, 2010 at 14:27 UTC
    read the value of each tag in xml file
    Maybe you could be more precise in your question... From XML::Parser, I find:

    Parse will return a parse tree for the document. Each node in the +tree takes the form of a tag, content pair. Text nodes are represented +with a pseudo-tag of "0" and the string that is their content.
    So you get pairs of tag and content. What is the stumbling block for you to extract only the tag and ignore the content?

    -- 
    Ronald Fischer <ynnor@mm.st>
Re: How i can read the value of each tag in xml file
by Jenda (Abbot) on Mar 03, 2010 at 08:58 UTC

    I do not think I understand. Please post a short example XML and the output you want to get.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.