Created
March 30, 2009 23:58
-
-
Save sbecker/87961 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# issue I'm having with Hpricot 0.7.232 (latest build I believe). | |
# So to be specific, inside a tag named "description" it seems to behave wrong, with .text returning all of the text in the XML from that point forward. | |
# If I change the name of the parent tag to anything else, it works right, returning just the text inside the tag. Weird eh? Here is some code, hopefully it formats in a readable way: | |
# Inside of a tag called 'description' - gives incorrect .text value: "test\n one,two\n" | |
>> xml = Hpricot.XML(%{ | |
<peon> | |
<id>1</id> | |
<description>test</description> | |
<tags>one,two</tags> | |
</peon>}) | |
=> #<Hpricot::Doc "\n" {elem <peon> "\n " {elem <id> "1" </id>} "\n " {elem <description> "test" {bogusetag </description>} "\n " {elem <tags> "one,two" {bogusetag </tags>} "\n" {bogusetag </peon>}}}}> | |
>> (xml/:peon/:description).text | |
=> "test\n one,two\n" | |
# Inside of a tag called something else, in this case 'descriptiona' - gives correct .text value: "test" | |
>> xml = Hpricot.XML(%{ | |
<peon> | |
<id>1</id> | |
<descriptiona>test</descriptiona> | |
<tags>one,two</tags> | |
</peon>}) | |
=> #<Hpricot::Doc "\n" {elem <peon> "\n " {elem <id> "1" </id>} "\n " {elem <descriptiona> "test" </descriptiona>} "\n " {elem <tags> "one,two" {bogusetag </tags>} "\n" {bogusetag </peon>}}}> | |
>> (xml/:peon/:descriptiona).text | |
=> "test" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment