python:libxml2: XRDS

hdknr@debiansept:~/xri_simplesign$ python2.5
Python 2.5 (release25-maint, Jul 20 2008, 20:47:25)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libxml2
>>> LS='http://xri.net/%s/?_xrd_r=application/xrds%%2Bxml;sep=false'
>>> doc=libxml2.parseFile(LS % '=hdknr')
>>> doc
<xmlDoc (http://xri.net/=hdknr/?_xrd_r=application/xrds%2Bxml;sep=false) object at 0xb7d6adec>
>>> doc.children
<xmlNode (XRDS) object at 0xb7b1d54c>
>>> doc.children.name
'XRDS'
>>> type(doc.children.children)
<type 'instance'>
>>> type(doc.children.children.children)
<type 'NoneType'>
>>> root=doc.getRootElement()
>>> root
<xmlNode (XRDS) object at 0xb78926ac>
>>> root.nodePath()
'/*'
>>> root.children
<xmlNode (text) object at 0xb7b1d3ec>
>>> root.children.next
<xmlNode (XRD) object at 0xb789282c>
>>> root.xpathEval2('/*/*')
[<xmlNode (XRD) object at 0xb78928ac>]

>>> root.serialize()
'<XRDS xmlns="xri://$xrds" ref="xri://=hdknr">\n <XRD xmlns="xri://$xrd*($v*2.0)" version="2.0">\n  <Query>*hdknr</Query>\n  <Status ceid="off" cid="verified" code="100"/>\n  <ServerStatus code="100"/>\n  <Expires>2008-12-15T06:27:37.000Z</Expires>\n  <ProviderID>xri://=</ProviderID>\n  <LocalID>!41be.68a8.d49e.e0c2</LocalID>\n  <CanonicalID>=!41BE.68A8.D49E.E0C2</CanonicalID>\n  <Service priority="10">\n   <ProviderID>xri://!!1003!103</ProviderID>\n   <Type match="null"/>\n   <Type select="true">xri://+i-service*(+contact)*($v*1.0)</Type>\n   <Path match="null"/>\n   <Path select="true">(+contact)</Path>\n   <URI append="authority" priority="1">http://linksafe-contact.ezibroker.net/contact/</URI>\n  </Service>\n  <Service priority="1">\n   <ProviderID>xri://!!1003!103</ProviderID>\n   <Type select="true">xri://+i-service*(+forwarding)*($v*1.0)</Type>\n   <Type match="null" select="false"/>\n   <Path match="default"/>\n   <Path>(+index)</Path>\n   <URI append="qxri" priority="1">http://linksafe-forward.ezibroker.net/forwarding/</URI>\n  </Service>\n  <Service priority="10">\n   <ProviderID>xri://!!1003!103</ProviderID>\n   <Type select="true">http://openid.net/signon/1.0</Type>\n   <URI append="none" priority="1">https://linksafe.ezibroker.net/server/</URI>\n  </Service>\n  <Service priority="1">\n   <Type match="null" select="false"/>\n   <Type select="true">xri://+i-service*(+photo)*($v*1.0)</Type>\n   <Path>(+index)</Path>\n   <Path match="default"/>\n   <URI append="qxri" priority="1">http://photo.debian.hdknr/</URI>\n  </Service>\n </XRD>\n</XRDS>'
>>> root.children.serialize()
'\n '
>>> root.children.next.serialize()
'<XRD xmlns="xri://$xrd*($v*2.0)" version="2.0">\n  <Query>*hdknr</Query>\n  <Status ceid="off" cid="verified" code="100"/>\n  <ServerStatus code="100"/>\n  <Expires>2008-12-15T06:27:37.000Z</Expires>\n  <ProviderID>xri://=</ProviderID>\n  <LocalID>!41be.68a8.d49e.e0c2</LocalID>\n  <CanonicalID>=!41BE.68A8.D49E.E0C2</CanonicalID>\n  <Service priority="10">\n   <ProviderID>xri://!!1003!103</ProviderID>\n   <Type match="null"/>\n   <Type select="true">xri://+i-service*(+contact)*($v*1.0)</Type>\n   <Path match="null"/>\n   <Path select="true">(+contact)</Path>\n   <URI append="authority" priority="1">http://linksafe-contact.ezibroker.net/contact/</URI>\n  </Service>\n  <Service priority="1">\n   <ProviderID>xri://!!1003!103</ProviderID>\n   <Type select="true">xri://+i-service*(+forwarding)*($v*1.0)</Type>\n   <Type match="null" select="false"/>\n   <Path match="default"/>\n   <Path>(+index)</Path>\n   <URI append="qxri" priority="1">http://linksafe-forward.ezibroker.net/forwarding/</URI>\n  </Service>\n  <Service priority="10">\n   <ProviderID>xri://!!1003!103</ProviderID>\n   <Type select="true">http://openid.net/signon/1.0</Type>\n   <URI append="none" priority="1">https://linksafe.ezibroker.net/server/</URI>\n  </Service>\n  <Service priority="1">\n   <Type match="null" select="false"/>\n   <Type select="true">xri://+i-service*(+photo)*($v*1.0)</Type>\n   <Path>(+index)</Path>\n   <Path match="default"/>\n   <URI append="qxri" priority="1">http://photo.debian.hdknr/</URI>\n  </Service>\n </XRD>'

>>> root.children.next.content
'\n  *hdknr\n  \n  \n  2008-12-15T06:27:37.000Z\n  xri://=\n  !41be.68a8.d49e.e0c2\n  =!41BE.68A8.D49E.E0C2\n  \n   xri://!!1003!103\n   \n   xri://+i-service*(+contact)*($v*1.0)\n   \n   (+contact)\n   http://linksafe-contact.ezibroker.net/contact/\n  \n  \n   xri://!!1003!103\n   xri://+i-service*(+forwarding)*($v*1.0)\n   \n   \n   (+index)\n   http://linksafe-forward.ezibroker.net/forwarding/\n  \n  \n   xri://!!1003!103\n   http://openid.net/signon/1.0\n   https://linksafe.ezibroker.net/server/\n  \n  \n   \n   xri://+i-service*(+photo)*($v*1.0)\n   (+index)\n   \n   http://photo.debian.hdknr/\n  \n '

>>> xrd=root.children.next
>>> xrd.name
'XRD'
>>> xrd.properties.serialize()
' version="2.0"'
>>> xrd.ns().serialize()
' xmlns="xri://$xrd*($v*2.0)"'
>>> xrd.ns().content
'xri://$xrd*($v*2.0)'
カテゴリー: 未分類 パーマリンク

コメントを残す