Professional Web Applications Themes

Rexml xpath question - Ruby

Hi, The following program: require 'rexml/doent' require 'rexml/xpath' require 'pp' doc = REXML::Doent.new(' <program> <item rnum="1"/> <item rnum="1:abc"/> </program>') REXML::XPath.each(doc.root, '/program/item[rnum="1"]') do |el| puts el end # end of example program produces: <item rnum='1'/> <item rnum='1:abc'/> Is this correct? I would have expected only the first item to be returned. Cheers,...

  1. #1

    Default Rexml xpath question

    Hi,

    The following program:

    require 'rexml/doent'
    require 'rexml/xpath'
    require 'pp'

    doc = REXML::Doent.new('
    <program>
    <item rnum="1"/>
    <item rnum="1:abc"/>
    </program>')

    REXML::XPath.each(doc.root, '/program/item[rnum="1"]') do |el|
    puts el
    end
    # end of example program

    produces:

    <item rnum='1'/>
    <item rnum='1:abc'/>

    Is this correct? I would have expected only the first item to be returned.

    Cheers,
    Han Guest

  2. #2

    Default Re: Rexml xpath question

    com (Han Holl) wrote in message news:<google.com>... 
    .... 

    Nope. That's a bug. Thanks for finding that; in the future, you
    might want to post the bug to the REXML bug page; I'm not reliable
    about reading this newsgroup.


    --- SER
    Sean Guest

  3. #3

    Default Re: Rexml xpath question

    On Tuesday, February 24, 2004, 7:04:48 AM, Sean wrote:
     
    > .... [/ref]
     


    REXML is distributed with Ruby, so you'll never be able to prevent
    people from posting issues here, and nor should you. The only
    reasonable process that can mitigate your lack of full attention to
    this forum (which I'm not criticising) is to ask somebody else to keep
    an eye out for you.

    That, or set a mail/NG filter that copies messages matching /rexml/i to a
    separate folder :)

    Cheers,
    Gavin



    Gavin Guest

  4. #4

    Default Re: Rexml xpath question

    com (Sean Russell) wrote in message
     

    Now that REXML is included in Ruby, I think (possible) bugs are of
    interest to the readers of this list. I might try to crosspost in
    the future, because it's not possible for people interested in Ruby
    to follow all specialized mailing lists.

    The irony is that this bug is just the behaviour that I wanted!
    Now I'll have to find out how to use starts-with. I'm afraid I
    don't find XPath syntax to be very intuitive.

    Cheers,

    Han Holl
    Han Guest

  5. #5

    Default Re: Rexml xpath question

    Gavin Sinclair <com.au> wrote in message news:<com.au>... 
    >
    >
    > REXML is distributed with Ruby, so you'll never be able to prevent
    > people from posting issues here, and nor should you. The only[/ref]

    Oh, I couldn't prevent people from posting here. What I'm saying is
    that if you post your bug report to this newsgroup, it may be a long
    while before I see it, and it may get lost entirely.

    If someone wants to give me access to an NNTP server that carries this
    newsgroup, with posting permissions, my ability to scan for bug
    reports would improve. However, it is unlikely that anybody is going
    to be successful at forcing me to spend more time trolling the
    newsgroups for bug reports anytime soon.

    REXML, like most open source projects, has an official bug reporting
    mechanism. Bugs posted there have a much better chance of being
    addressed.
     

    Are you volunteering? That is, after all, what Ruby (and REXML) is:
    volunteer work. Things would be different if I were being paid for
    this :-)

    --- SER
    Sean Guest

  6. #6

    Default Re: Rexml xpath question

    com (Han Holl) wrote in message news:<google.com>... 

    Yeah, that's the downside to REXML in Ruby. There is a dedicated
    REXML mailing list, a dedicated bug tracking system, and a dedicated
    web page. There is a bunch of doentation that isn't included in
    the Ruby CVS system. I'm reluctant to cross-post from the REXML
    mailing list to the newsgroup simply because I think there's enough
    noise in the group as it is; that wouldn't solve the core problem that
    people using REXML these days may not even realize that there exists a
    separate forum for it.
     

    Yeah, XPath can be tricky, but it is pretty simple once you get the
    hang of it, until you start doing complex filtering.

    You had it almost right, though:

    /program/item[ starts-with( rnum ) = "1"]

    --- SER
    Sean Guest

Similar Threads

  1. xpath question!
    By charlie656 in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: January 20th, 12:09 AM
  2. XFactorStudio xpath question
    By Wolli World in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: December 3rd, 05:15 AM
  3. ANN: REXML 2.7.4
    By Sean in forum Ruby
    Replies: 8
    Last Post: February 26th, 03:44 AM
  4. Replies: 2
    Last Post: January 13th, 12:36 AM
  5. Replies: 2
    Last Post: July 16th, 09:49 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139