Skip to content

Instantly share code, notes, and snippets.

@QNENet
Created November 24, 2009 23:12
Show Gist options
  • Save QNENet/242324 to your computer and use it in GitHub Desktop.
Save QNENet/242324 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'nokogiri'
doc = Nokogiri::XML(
<<-EOXML
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) XBRL International. See http://www.xbrl.org/legal -->
<schema elementFormDefault="qualified" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.xbrl.org/int/gl/plt/2009-10-21" attributeFormDefault="unqualified" xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:gl-plt="http://www.xbrl.org/int/gl/plt/2009-10-21">
<annotation>
<appinfo>
<link:linkbaseRef xlink:type="simple" xlink:href="../../cor/lang/gl-cor-2009-10-21-label.xml" xlink:title="Label Links, all" xlink:role="http://www.xbrl.org/2003/role/labelLinkbaseRef" xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase"/>
<link:linkbaseRef xlink:type="simple" xlink:href="../../cor/lang/gl-cor-2009-10-21-label-ja.xml" xlink:title="Label Links, ja" xlink:role="http://www.xbrl.org/2003/role/labelLinkbaseRef" xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase"/>
</appinfo>
</annotation>
<import namespace="http://www.xbrl.org/int/gl/cor/2009-10-21" schemaLocation="gl-cor-content-2009-10-21.xsd"/>
</schema>
EOXML
)
doc.root.children.each do |child|
puts child.name
end
puts "\n\n"
puts doc.at_xpath("//annotation") # FAILS to find
puts "\n\n"
puts doc.at_xpath("//import") # FAILS to find
puts "\n\n"
puts doc.xpath("//link:linkbaseRef").first # FINDS OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment