Find value of child node

OneLove

New Member
Ok, this is a pretty rudimentary question, but I'm new to Perl and I honestly can't seem to find the answer anywhere, even though I'm sure it will be ridiculously simple. Let's say I have the following XML schema:\[code\]<root> <parentNode status="Good"> <A> <B> <value><![CDATA[This is my value]]</value> </B> </A> </parentNode></root>\[/code\]Assume there are going to be multiple parentNodes with varying statuses.I'm trying to write a script that will give me the content of each of the value nodes of the parentNodes where status isn't "Good"Using the following code I've been able to successfully get the correct parentNodes:\[code\]my $parser = XML::LibXML->new();my $tree = $parser->parse_file($xml_file);my $root = $tree->getDocumentElement;my @records = $root->findnodes("//parentNode");foreach my $node (@records) { my $resultAtt = $node->getAttribute('status'); next if $resultAtt ne "Good";\[/code\]But when I try: \[code\]my $val = $node->findvalue("value");\[/code\]I get nothing. Additionally, I'm really just interested in the "This is my value" part. When you read the value, does the CDATA affect it at all?
 
Back
Top