GithubHelp home page GithubHelp logo

Comments (2)

ohler55 avatar ohler55 commented on June 2, 2024

From your example it looks like Ox is acting as documented. If your intent is to find any element that matches the nested names then you need to use wild cards. Check out the docs on #locate for some examples. If you are still having trouble let me know and I can lead you through and example. Give me a day or two though. I still do not have an internet connection after my move to the USA.

On Aug 31, 2012, at 10:01 AM, Mani Tadayon [email protected] wrote:

I had a lot of trouble with XML documents (returned by a 3rd party) that had node names with dashes in them.

Here's a sample IRB session that demonstrates the bug:

irb(main):001:0> require 'ox'
true
irb(main):002:0> xml = <<-EOS
irb(main):003:0"
irb(main):004:0"
irb(main):005:0" hihi
irb(main):006:0"
irb(main):007:0"
irb(main):008:0" hi
irb(main):009:0"
irb(main):010:0"
irb(main):011:0"
irb(main):012:0"
irb(main):013:0"
irb(main):014:0" EOS
"\n\n hihi\n \n \n hi\n \n \n \n \n\n"
irb(main):015:0> ox_doc = Ox.parse xml
#<Ox::Document:0x101e2fd68
attr_reader :attributes = {
:version => "1.0"
},
attr_reader :nodes = [
[0] #<Ox::Element:0x101e2fca0
attr_accessor :value = "xml-response",
attr_reader :nodes = [
[0] #<Ox::Element:0x101e2fc28
attr_accessor :value = "nodashesnode",
attr_reader :nodes = [
[0] "hihi"
]
>,
[1] #<Ox::Element:0x101e2fb88
attr_accessor :value = "clear-tradeline",
attr_reader :nodes = [
[0] #<Ox::Element:0x101e2fb10
attr_accessor :value = "supplier-tradeline",
attr_reader :nodes = [
[0] #<Ox::Element:0x101e2fa98
attr_accessor :value = "clear-tradeline-reason-code-description",
attr_reader :nodes = [
[0] "hi"
]
>,
[1] #<Ox::Element:0x101e2f9f8
attr_accessor :value = "some-dashed-node",
attr_reader :nodes = []
>,
[2] #<Ox::Element:0x101e2f980
attr_accessor :value = "nodashesnode",
attr_reader :nodes = []
>
]
>
]
>
]
>
]

irb(main):016:0> ox_doc.locate 'clear-tradeline-reason-code-description'
[]
irb(main):017:0> ox_doc.locate 'nodashesnode'
[]
irb(main):018:0> ox_doc.locate 'xml-response'
[
[0] #<Ox::Element:0x101e2fca0
attr_accessor :value = "xml-response",
attr_reader :nodes = [
[0] #<Ox::Element:0x101e2fc28
attr_accessor :value = "nodashesnode",
attr_reader :nodes = [
[0] "hihi"
]
>,
[1] #<Ox::Element:0x101e2fb88
attr_accessor :value = "clear-tradeline",
attr_reader :nodes = [
[0] #<Ox::Element:0x101e2fb10
attr_accessor :value = "supplier-tradeline",
attr_reader :nodes = [
[0] #<Ox::Element:0x101e2fa98
attr_accessor :value = "clear-tradeline-reason-code-description",
attr_reader :nodes = [
[0] "hi"
]
>,
[1] #<Ox::Element:0x101e2f9f8
attr_accessor :value = "some-dashed-node",
attr_reader :nodes = []
>,
[2] #<Ox::Element:0x101e2f980
attr_accessor :value = "nodashesnode",
attr_reader :nodes = []
>
]
>
]
>
]

]

Reply to this email directly or view it on GitHub.

from ox.

bowsersenior avatar bowsersenior commented on June 2, 2024

Thanks for your comments. I will look at the docs and see if I can figure out the problem. We were using Hpricot with these same XPath queries but there may be a difference between Ox and Hpricot with how these are handled.

from ox.

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.