xml-motor 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README +3 -0
- data/lib/xml-motor.rb +14 -3
- data/lib/xml-motor/version.rb +1 -1
- metadata +1 -1
data/README
CHANGED
@@ -51,6 +51,9 @@ An easy-to-use XML Parser without any Native Dependencies.
|
|
51
51
|
=====================================================================
|
52
52
|
CHANGE-LOG
|
53
53
|
=====================================================================
|
54
|
+
Changes from v0.0.6 to v0.0.7
|
55
|
+
[] correcting the attribute matching to be sensitive to single and double quotes
|
56
|
+
=====================================================================
|
54
57
|
Changes from v0.0.5 to v0.0.6
|
55
58
|
[] correcting the attribute parsing to handle line-change well, corrected my mistake
|
56
59
|
=====================================================================
|
data/lib/xml-motor.rb
CHANGED
@@ -5,6 +5,17 @@ module XMLStdout
|
|
5
5
|
def self._nfo(mesag); puts "INFORMATION:: #{mesag}"; end
|
6
6
|
end
|
7
7
|
|
8
|
+
module XMLUtils
|
9
|
+
def self.dbqot_string(attrib_val)
|
10
|
+
return nil if attrib_val.nil?
|
11
|
+
matched_data = attrib_val.strip.match(/^'(.*)'$/)
|
12
|
+
return attrib_val if matched_data.nil?
|
13
|
+
matched_data = matched_data[0].gsub("\"","'")
|
14
|
+
matched_data[0] = matched_data[-1] = "\""
|
15
|
+
matched_data
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
8
19
|
module XMLIndexHandler
|
9
20
|
def self.get_node_indexes(xml_motor, tag)
|
10
21
|
xml_idx_to_find = []
|
@@ -68,11 +79,11 @@ module XMLChopper
|
|
68
79
|
broken_attrib[1..-2].each do |attrib_part|
|
69
80
|
value_n_attrib = attrib_part.split
|
70
81
|
values = value_n_attrib[0..-2].join(' ')
|
71
|
-
attrs[attribs] = values
|
82
|
+
attrs[attribs] = XMLUtils.dbqot_string values
|
72
83
|
attribs = value_n_attrib[-1].strip
|
73
84
|
end
|
74
85
|
values = broken_attrib.last.strip
|
75
|
-
attrs[attribs] = values
|
86
|
+
attrs[attribs] = XMLUtils.dbqot_string values
|
76
87
|
attrs
|
77
88
|
end
|
78
89
|
end
|
@@ -134,7 +145,7 @@ module XMLMotorEngine
|
|
134
145
|
node_stop = xml_to_find[ncount*2 +1]
|
135
146
|
unless attrib_to_find.nil?
|
136
147
|
next if @xmlnodes[node_start][0][1].nil?
|
137
|
-
next unless @xmlnodes[node_start][0][1][attrib_key] == attrib_val
|
148
|
+
next unless @xmlnodes[node_start][0][1][attrib_key] == XMLUtils.dbqot_string(attrib_val)
|
138
149
|
end
|
139
150
|
nodes[ncount] ||= ""
|
140
151
|
nodes[ncount] += @xmlnodes[node_start][1] unless @xmlnodes[node_start][1].nil?
|
data/lib/xml-motor/version.rb
CHANGED