Identifying where bad XML is

Discussion in 'Ruby' started by Ben Burdick, Sep 22, 2005.

  1. Ben Burdick

    Ben Burdick Guest

    I am somewhat new to ruby and would appreciate any help on this
    matter. I have a custom assertion for running tests
    "assert_valid_xml_response" - which will parse the output and check
    for any bad xml..

    My problem is, that with many changes constantly taking place, and
    many of these assertions taking place, it is sometimes hard to
    pinpoint exactly where the bad XML is hiding.

    Has anyone stumbled across a solution to easily zero in on the
    location of bad XML?
    Ben Burdick, Sep 22, 2005
    #1
    1. Advertising

  2. Ben Burdick

    James Britt Guest

    Ben Burdick wrote:
    > I am somewhat new to ruby and would appreciate any help on this
    > matter. I have a custom assertion for running tests
    > "assert_valid_xml_response" - which will parse the output and check for
    > any bad xml..
    >
    > My problem is, that with many changes constantly taking place, and many
    > of these assertions taking place, it is sometimes hard to pinpoint
    > exactly where the bad XML is hiding.
    >
    > Has anyone stumbled across a solution to easily zero in on the location
    > of bad XML?


    Um, depends on what is making it bad.

    If I have access to the complete XML document, then I try loading it
    into IE or Firefox, which are pretty good at locating problems and
    issuing useful info.

    Or I run it though tidy or xmllint or something.

    Often the problem is a stray '<' or '&' someplace, so grep + a decent
    regexp could track it down, too.

    If the XML is a set of repeated structures you could try using the REXML
    stream or pull parser to read in chunks at a time and assemble smaller
    sub-docs, and check those for well-formedness. If it fails it's easier
    to then to write out the failing XML and inspect it.


    James
    --

    http://www.ruby-doc.org - The Ruby Documentation Site
    http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
    http://www.rubystuff.com - The Ruby Store for Ruby Stuff
    http://www.jamesbritt.com - Playing with Better Toys
    James Britt, Sep 22, 2005
    #2
    1. Advertising

  3. Ben Burdick <> wrote:
    > I am somewhat new to ruby and would appreciate any help on this
    > matter. I have a custom assertion for running tests
    > "assert_valid_xml_response" - which will parse the output and check
    > for any bad xml..
    >
    > My problem is, that with many changes constantly taking place, and
    > many of these assertions taking place, it is sometimes hard to
    > pinpoint exactly where the bad XML is hiding.
    >
    > Has anyone stumbled across a solution to easily zero in on the
    > location of bad XML?


    What exactly do you mean by "bad"? Do you mean "ill formed"? In that case
    any decent XML parser (validating and non validating) should give you
    information about where it chokes. If you mean by "bad" that it doesn't fit
    an XML Schema or DTD then a validating parser should point you where the
    error lies.

    Kind regards

    robert
    Robert Klemme, Sep 22, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    850
  2. Eric Anderson

    Bad Transform or Bad Engine?

    Eric Anderson, Oct 4, 2005, in forum: XML
    Replies:
    1
    Views:
    363
    Peter Flynn
    Oct 5, 2005
  3. =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=

    vs2005 publish website doing bad things, bad things

    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=, Oct 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    587
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Oct 25, 2006
  4. James Harris

    Identifying a class type - bad practice?

    James Harris, Aug 18, 2009, in forum: Python
    Replies:
    6
    Views:
    264
  5. rantingrick
    Replies:
    44
    Views:
    1,171
    Peter Pearson
    Jul 13, 2010
Loading...

Share This Page