Giter Site home page Giter Site logo

Xml not parsing properly about crack HOT 1 CLOSED

jnunemaker avatar jnunemaker commented on July 4, 2024
Xml not parsing properly

from crack.

Comments (1)

sr75 avatar sr75 commented on July 4, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.