What you were trying wasn't clear to me , so I did it as I see it. First, your xml isn't valid---the schema messed-up <build>. Second, I usually avoid glob when I do XML---better to use findnodes or something similar. Here's the script that I ran:
#!/usr/bin/perl use strict; use warnings; use XML::LibXML; my @files = '/root/Desktop/your.xml'; my $parser = XML::LibXML->new(); foreach my $file( @files) { my $doc = $parser->parse_file($file); my $cmm_root_path_var = $doc->findnodes("//Test/*"); print $doc->to_literal(), "\n"; }
And I ran your xml through xmltidy. It's still not valid, but works for this test:
<?xml version="1.0" encoding="utf-8"?> <build> <name>lpass</name> <build_id>M8960AAAAANAAL1004</build_id> <windows_root_path cmm_root_path_var="PASS_BUILD_ROOT">\\TEST\M965 +0AAAAANAAL1004\</windows_root_path> <linux_root_path cmm_root_path_var="PASS_BUILD_ROOT" /> <image_dir>lpass_proc</image_dir> <name>rpm</name> <build_id>M8960AAAAANAAR1004</build_id> <windows_root_path cmm_root_path_var="PM_BUILD_ROOT">\\TEST\M9650AAA +AANAAR1004\</windows_root_path> <linux_root_path cmm_root_path_var="PM_BUILD_ROOT" /> <image_dir>rpm_proc</image_dir> <download_file> <file_name>rpm.mbn</file_name> <file_path>rpm_proc/</file_path> </download_file> <name>wcnss</name> <build_id>M8960AAAAANAAW1004</build_id> <windows_root_path cmm_root_path_var="NSS_BUILD_ROOT">\\TEST\M9650AA +AAANAAW1004\</windows_root_path> <linux_root_path cmm_root_path_var="NSS_BUILD_ROOT" /> <image_dir>wcnss_proc</image_dir> </build>

In reply to Re: Parsing an xml file by Khen1950fx
in thread Parsing an xml file by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.