rexml_test.rb

modified rexml test - tenderlovemaking (Aaron Patterson), 12/03/2009 12:20 pm

Download (847 Bytes)

 
1
require 'nokogiri'
2
require 'rexml/document'
3

    
4
docstring = <<EOS
5
<?xml version="1.0" encoding="ISO-8859-1"?>
6
<!DOCTYPE x SYSTEM "licenseOut.xsd">
7
<a>
8
    <c>A bigger than B</c>
9
</a>
10
EOS
11

    
12
nd = Nokogiri::XML.parse(docstring)
13
noko_value = nd.xpath("//c").text
14
puts("noko_value: #{noko_value}")
15

    
16
xml_doc = REXML::Document.new(docstring)
17
return_string = xml_doc.root.elements["//c"].text
18
puts("return_string: #{return_string}")
19
########################################################
20
docstring = <<EOS
21
<?xml version="1.0" encoding="ISO-8859-1"?>
22
<!DOCTYPE x SYSTEM "licenseOut.xsd">
23
<a>
24
    <c>A &gt; B</c>
25
</a>
26
EOS
27

    
28
nd = Nokogiri::XML.parse(docstring)
29
noko_value = nd.xpath("//c").text
30
puts("noko_value: #{noko_value}")
31

    
32
xml_doc = REXML::Document.new(docstring)
33
return_string = xml_doc.root.elements["//c"].text
34
puts("return_string: #{return_string}")