in reply to How might one determine empty XML payload?
Hi vlturner,
Here's one way:
my $xml = q{<?xml version="1.0" encoding="UTF-8"?><response></response +>}; my $dom = XML::LibXML->load_xml(string=>$xml); my $isEmpty = !$dom->documentElement->nonBlankChildNodes; print "isEmpty: ", ($isEmpty?"yes":"no"), "\n"; __END__ isEmpty: yes
This method has the advantage that whitespace inside the <response> tag is ignored. If you don't want that, and want to know specifically when the <response> tag has no content at all, use hasChildNodes instead of nonBlankChildNodes.
Hope this helps,
-- Hauke D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How might one determine empty XML payload?
by vlturner (Sexton) on Jun 02, 2016 at 14:11 UTC | |
by haukex (Archbishop) on Jun 02, 2016 at 14:30 UTC | |
by vlturner (Sexton) on Jun 02, 2016 at 14:56 UTC | |
by GotToBTru (Prior) on Jun 02, 2016 at 16:15 UTC | |
by vlturner (Sexton) on Jun 02, 2016 at 17:15 UTC | |
|