comparing xml

Discussion in 'Ruby' started by ara.t.howard, Mar 23, 2009.

  1. ara.t.howard

    ara.t.howard Guest

    ara.t.howard, Mar 23, 2009
    #1
    1. Advertisements

  2. ara.t.howard

    Phlip Guest

    Use LibXML-Ruby, Nokogiri, or REXML, read both documents, and convert them to DOMs.

    Recursively compare each node, and all its children, to the matching node in the
    other document, and fault if anythings out of tolerance.
     
    Phlip, Mar 23, 2009
    #2
    1. Advertisements

  3. ara.t.howard

    ara.t.howard Guest



    err - that is precisely what that code is doing?


    a @ http://codeforpeople.com/
     
    ara.t.howard, Mar 23, 2009
    #3
  4. ara.t.howard

    ara.t.howard Guest

    it *is* comparing strings, but strings built up inside rexml using the
    approach you outlined.


    ah - good catch - i'll check on that. my alternate approach,
    comparing xmlsimple data structures will not, i believe, suffer from
    that, but i wanted to avoid a dependancy.

    i'll check and report back

    cheers.

    a @ http://codeforpeople.com/
     
    ara.t.howard, Mar 23, 2009
    #4
  5. ara.t.howard

    Phlip Guest

    If so, would that break over details like attributes out of order?
    I caught it because I just recently solved a subset of your problem.
    assert_xhtml uses Nokogiri to match a subset of HTML within a page. The code is
    too weird for you to use, but I indeed had to defeat all the issues you will
    encounter!
     
    Phlip, Mar 23, 2009
    #5
  6. ara.t.howard

    ara.t.howard Guest

    next version is up

    http://gist.github.com/83721


    a @ http://codeforpeople.com/
     
    ara.t.howard, Mar 23, 2009
    #6
  7. ara.t.howard

    ara.t.howard Guest


    latest version handles the first and i'm ok with the later. feeling
    like this is reasonably complete now. crazy none of the ruby xml libs
    offer a good doc==other.

    cheers.

    a @ http://codeforpeople.com/
     
    ara.t.howard, Mar 24, 2009
    #7
  8. ara.t.howard

    Phlip Guest

    That is _supposed_ to be XSLT's space. Don't hold your breath. I'm beginning to
    suspect XSLT just might be a mission-statement without a company for it to
    guide! (-:
     
    Phlip, Mar 24, 2009
    #8
  9. ara.t.howard

    ara.t.howard Guest


    that is the one with 'bacon' isn't it?


    a @ http://codeforpeople.com/
     
    ara.t.howard, Mar 24, 2009
    #9
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.