xml_parser 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc02cb0aed38ab5e931fa76958e3d4cfb43266e1
4
- data.tar.gz: b875268acaa289c6fea37828d79d3432faecb9dc
3
+ metadata.gz: 98a5fc0719d620a1f7778f325fa84790bddebd1b
4
+ data.tar.gz: aa967cb4fa2a611211a5d53daee4ddba4427e3a2
5
5
  SHA512:
6
- metadata.gz: 1897c41ffa71821789c9b34cb0dbcb5be8b5de7984e920c3ad4b146171e1116de16dd8b814bd76a284a3875315c0ea80de4d735d1c4f5b642dcb87f1eefd4a7b
7
- data.tar.gz: 48d633a09b99c1196f5492f0503db54c3c0359c7160071efacc232587e9d52ecb2e976e9798a293780df5e9f65353f131c4f708dd76f172cfd66f08e486d5d85
6
+ metadata.gz: 911cd14d34160dc528fa5e3992d57c3effe48270858d8f6caf610ab744b63faaec8cb1b49d44116f2c6c7b5bb63930eef0b2dee24eddf957b31dba87537f94df
7
+ data.tar.gz: 24354755fe0d9d5828c6604a19ae8cf9dad973bf219dcd6f6a6828ba7a45fcc28f8715f98d651cfec08919954848457065465308fdfe91316ae0084ef754278c
@@ -1,4 +1,5 @@
1
1
  require "rexml/document"
2
+ require "rexml/formatters/default"
2
3
  require "yaml"
3
4
  require "pp"
4
5
 
@@ -52,6 +53,22 @@ module XmlParser
52
53
  }
53
54
  end
54
55
 
56
+ # if xpath match, to string.
57
+ # @param [String] xpath xpath
58
+ # @return [String] xpath match result.
59
+ def xpath_to_s(xpath)
60
+
61
+ formatter = REXML::Formatters::Default.new
62
+ out = StringIO.new
63
+
64
+ # search by xpath.
65
+ REXML::XPath.match(@doc, xpath).each { |elm|
66
+ formatter.write(elm, out)
67
+ }
68
+
69
+ out.string
70
+ end
71
+
55
72
  # xml decl info.
56
73
  # @return [REXML::XMLDecl] xml decl
57
74
  def decl
@@ -1,3 +1,3 @@
1
1
  module XmlParser
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
data/xml_parser.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["corporation.ore@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Parse Xml Document and String.}
13
- spec.description = %q{Parse Xml Document and String.From String, and File.}
13
+ spec.description = %q{Parse Xml Document and String. From String, Hash and XML File, Yaml File.}
14
14
  spec.homepage = "https://github.com/h-shigemoto/xml_parser"
15
15
  spec.license = "MIT"
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - h.shigemoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-28 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- description: Parse Xml Document and String.From String, and File.
55
+ description: Parse Xml Document and String. From String, Hash and XML File, Yaml File.
56
56
  email:
57
57
  - corporation.ore@gmail.com
58
58
  executables: []