Comments (1)
I had the same issue with default xml parser. Seems the httparty default xml parser isn't a one for one implemenation of the Crack::XML.parse functionality. The crack xml parser allows you to get at attributes in the hash. The httparty parsed response doesn't, I've verified this in rspec tests because a project I'm working on requires me to parse the attributes for processing certain logic.
<root><action condition="email">threshold not met, email response</action></root>
Here's a workaround to get at xml attributes using Crack::XML.parse:
def self.submit(submission, setting)
Crack::XML.parse(get(setting.uri, query: build_insert_query_string(submission, setting)))
end
xml_doc = Wonky::Webservice.submit(submission, setting)
- using crack the xml attributes are accessible via [][] syntax
- if you don't use crack the default httparty xml parser doesn't include attributes and errors when trying to access the attribute key
- default parser only includes the content of the tags in the parsed hash
using the crack parser you would get at the attributes like so:
puts xml_doc['root']['action'].attributes
puts xml_doc['root']['action'].attributes['condition'] # condition is an attribute of action tag
So to get this working as advertised, Httparty needs some tests for the xml parsing scenarios involving attributes to make sure it's implementing the full Crack::XML.parse functionality for xml attributes.
from crack.
Related Issues (20)
- YAML load errors when parsing JSON that initially contained a \u0000 character sequence HOT 2
- Psych::SyntaxError while parsing JSON using rails 3.0.2/ruby 1.9.2p180 HOT 9
- Crack treats JSON parsing errors differently depending on the underlying YAML parser HOT 1
- parsing of XML return a singleton Hash that is not dumpable HOT 4
- Add bigdecimal to gemspec HOT 1
- many json tests are failing with ruby 1.9 HOT 2
- Fails to run Jekyll 1.0.3 (conflicting versions of safe_yaml) on Mac OSX 10.8.3 HOT 1
- Support for Attributes HOT 2
- Crack::JSON is not parsing UTF-8 correctly HOT 1
- Crack::JSON can't parse valid json string with UTF-8 character
- Issue with array of elements when the key is an attribute of the nodw HOT 2
- Key mangling when using two dates HOT 1
- Crack 0.4.3 cannot parse two consecutive dates HOT 1
- Xml parsing dont return attribute of tag HOT 1
- make a 1.0.0 release? HOT 5
- Remove `test/` from bundled gem HOT 4
- Please include license file in the gem. HOT 1
- Missing v0.4.5 tag HOT 2
- JSON failures with Ruby 3.1 / Psych 4.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crack.