Comments (2)
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.
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)
- Various thoughts HOT 10
- Use "interned" (frozen and deduplicated) Strings in Ruby 3.0+ to minimize object allocations. HOT 3
- Become `Ractor`-safe to allow usage in non-main `Ractor`. HOT 1
- Bundle install failing HOT 7
- Parse error for comments containing special characters inside a DOCTYPE declaration HOT 1
- Single carriage return is not converted to line feed HOT 16
- Easy way to get backtrace information from the C extension? HOT 18
- Process XML with instructions longer than 1024 characters. HOT 9
- Ox 2.14.7 causes segfault HOT 14
- RESX XML parsing - support for xml:space="preserve" HOT 3
- Preserve newlines in attributes and bodies when parsing. HOT 2
- [BUG] Bus Error (crashes ruby when using more than 16458 characters in a field) HOT 5
- Request to include a new mode to load which prepends xml attributes with a given string or a default HOT 1
- Ox.load result changes after parsing specific xml. HOT 2
- Sax parser segfault in v2.14.7+ HOT 4
- `StringIO` in `Ox::Builder` HOT 2
- Sax parsing with default encoding set to UTF-8 breaks Ox::Sax#text HOT 2
- OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE is not shareable across ractors HOT 1
- Issue with gems on M1 that depends on ox HOT 3
- test/tests.rb fails with ruby3.2.0preview3 and onwards HOT 3
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 ox.