Skip to content

Instantly share code, notes, and snippets.

@cfedde
Last active December 24, 2015 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfedde/6718581 to your computer and use it in GitHub Desktop.
Save cfedde/6718581 to your computer and use it in GitHub Desktop.
Test case for how I suspect I'll be able to get at the "type=" attribute of this xml frag.
#!/usr/bin/env perl
use Modern::Perl;
use Mojo::DOM;
use Test::More;
my $xml = q|<?xml version="1.0" encoding="ISO-8859-1"?>
<command type="Error" xmlns="" xmlns:c="C" xsi:type="c:ErrorResponse"><summary>[Error 4007] Invalid login ID: cfedde001c_as01</summary><summaryEnglish>[Error 4007] Invalid login ID: cfedde001c_as01</summaryEnglish></command>
|;
my $r = Mojo::DOM->new()->xml(1)->parse($xml);
ok($r->xml(), "\$r is xml");
ok($r->at('command')->type() eq 'command', "command is a command");
ok($r->at('command')->attr('type') eq "Error", "attr type eq Error");
ok($r->at('command')->type() eq 'command', "command is a command");
done_testing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment