Have an xml file in which one parent tag has multiple child tags and each of these tags have some value. I need to get all child node values in an array, iterate through each and perform specific task on values. When I try to get records what I am ending up is with entire child node as a single element of an array. How do read each child as an seperate element of an array. What I am using is XML::LibXML
<?xml version="1.0" encoding="UTF-8"?> <cidconfig> <createnew> <logon>xxx,xxx</logon> <startnew>xxx,xxx</startnew> <choosecs>xxx,xxx</choosecs> <chooseapp>xxx,xxx</chooseapp> <chooseconfig>xxx,xxx</chooseconfig> <chooseconftype>xxx,xxx</chooseconftype> <startnew1>xxx,xxx</startnew1> <activate>xxx,xxx</activate> </createnew> </cidconfig> Code I have written use strict; use warnings; use diagnostics; use XML::LibXML; my $dom = XML::LibXML->load_xml(location => $ARGV[0]); my $root = $dom->getDocumentElement; my @records = $root->findnodes("//createnew"); print @records; foreach my $y (@records) { my $x = $y->childNodes; print "$x"; print "Yes\n"; } Output <createnew> <logon>xxx,xxx</logon> <startnew>xxx,xxx</startnew> <choosecs>xxx,xxx</choosecs> <chooseapp>xxx,xxx</chooseapp> <chooseconfig>xxx,xxx</chooseconfig> <chooseconftype>xxx,xxx</chooseconftype> <startnew1>xxx,xxx</startnew1> <activate>xxx,xxx</activate> </createnew> xxx,xxx xxx,xxx xxx,xxx xxx,xxx xxx,xxx xxx,xxx xxx,xxx xxx,xxx Yes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |