<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff></diff>
      <filename>flowcontrol.dia</filename>
    </modified>
    <modified>
      <diff>@@ -61,10 +61,13 @@ sub parse {
 
     # Get XRDS
     my $xrds = shift @{$doc-&gt;getElementsByTagName('xrds:XRDS')};
+    $xrds = shift @{$doc-&gt;getElementsByTagName('XRDS')} unless $xrds;
+    return unless $xrds;
 
     # Get /last/ XRD
     my @xrd = $xrds-&gt;getElementsByTagName('XRD');
     my $xrd = $xrd[-1];
+    return unless $xrd;
 
     my $services = [];
     my @services = $xrd-&gt;getElementsByTagName('Service');
@@ -145,7 +148,6 @@ Protocol::Yadis::Document - Protocol::Yadis document object
           &lt;/Service&gt;
          &lt;/XRD&gt;
         &lt;/xrds:XRDS&gt;
-    EOD
 
     my $services = $d-&gt;services;
 </diff>
      <filename>lib/Protocol/Yadis/Document.pm</filename>
    </modified>
    <modified>
      <diff>@@ -1,15 +1,52 @@
-use Test::More tests =&gt; 37;
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests =&gt; 41;
 
 use Protocol::Yadis::Document;
 
 my $d = Protocol::Yadis::Document-&gt;parse;
-ok(not defined);
+ok(not defined $d);
 
 $d = Protocol::Yadis::Document-&gt;parse('');
-ok(not defined);
+ok(not defined $d);
 
 $d = Protocol::Yadis::Document-&gt;parse('&lt;asdasd');
-ok(not defined);
+ok(not defined $d);
+
+$d = Protocol::Yadis::Document-&gt;parse(&lt;&lt;'');
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+&lt;foo xmlns:xrds=&quot;xri://$xrds&quot; xmlns=&quot;xri://$xrd*($v*2.0)&quot;&gt;
+ &lt;XRD&gt;
+ &lt;/XRD&gt;
+&lt;/foo&gt;
+
+ok(not defined $d);
+
+$d = Protocol::Yadis::Document-&gt;parse(&lt;&lt;'');
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+&lt;xrds:XRDS xmlns:xrds=&quot;xri://$xrds&quot; xmlns=&quot;xri://$xrd*($v*2.0)&quot;&gt;
+&lt;/xrds:XRDS&gt;
+
+ok(not defined $d);
+
+$d = Protocol::Yadis::Document-&gt;parse(&lt;&lt;'');
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+&lt;XRDS xmlns=&quot;xri://$xrds&quot;&gt;
+ &lt;XRD xmlns=&quot;xri://$xrd*($v*2.0)&quot;&gt;
+  &lt;Service&gt;
+   &lt;Type&gt; http://lid.netmesh.org/sso/2.0 &lt;/Type&gt;
+  &lt;/Service&gt;
+  &lt;Service&gt;
+   &lt;Type&gt; http://lid.netmesh.org/sso/1.0 &lt;/Type&gt;
+  &lt;/Service&gt;
+ &lt;/XRD&gt;
+&lt;/XRDS&gt;
+
+is($d-&gt;services-&gt;[0]-&gt;Type-&gt;[0]-&gt;content, 'http://lid.netmesh.org/sso/2.0');
+is($d-&gt;services-&gt;[1]-&gt;Type-&gt;[0]-&gt;content, 'http://lid.netmesh.org/sso/1.0');
 
 $d = Protocol::Yadis::Document-&gt;parse(&lt;&lt;'');
 &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</diff>
      <filename>t/document.t</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>def2c0a59f96aab5c82e2199fa1253d4e96fc569</id>
    </parent>
  </parents>
  <author>
    <name>vti</name>
    <email>viacheslav.t@gmail.com</email>
  </author>
  <url>http://github.com/vti/protocol-yadis/commit/9da599366b74c44bb6e5a95a5c20a4cc61511af6</url>
  <id>9da599366b74c44bb6e5a95a5c20a4cc61511af6</id>
  <committed-date>2009-11-10T03:10:10-08:00</committed-date>
  <authored-date>2009-11-10T03:10:10-08:00</authored-date>
  <message>Made document parsing more robust</message>
  <tree>dcb3d916706475a5aad1f9efd9435a07b48871d7</tree>
  <committer>
    <name>vti</name>
    <email>viacheslav.t@gmail.com</email>
  </committer>
</commit>
