Hello,

Warning: I'm a Perl/XML newbie. I have an interesting (at least I think so) XML problem that I was hoping to solve with Perl and its XML extensions. I've been hanging out on the site (surfing some previous postings regarding the specific modules that I've been playing with) and I'm just about through the Perl & XML O'Reilly book (really enjoyed the read). Enough chit chat.

I'm using Matt Sergeant's XML::Generator::DBI module to query my data source and return an XML document similar to the following:

<?xml version="1.0" encoding="UTF-8"?> . . . <Message> <MessageID>376</MessageID> <CreateDate>2002-05-31 09:14:41.047</CreateDate> <Subject>Re: Msg54</Subject> </Message> <Message> <MessageID>377</MessageID> <CreateDate>2002-06-04 08:47:47.627</CreateDate> <Subject>Re: Msg95</Subject> </Message> <Message> <MessageID>378</MessageID> <CreateDate>2002-06-04 08:51:58.390</CreateDate> <Subject>Demo</Subject> </Message> <Message> <MessageID>379</MessageID> <CreateDate>2002-06-04 08:54:38.593</CreateDate> <Subject>Re: Demo</Subject> </Message> . . .
The problem is that I have to extract (inclusively) the data between each <Message>...</Message> section and write each chunk to its own file using the value in <MessageID>...</MessageID> for the file name. I understand that this module generates SAX events as a result of the query however, I was considering building a DOM tree and using XPath to extract the necessary text. Can anyone offer any advice on my purposed method of attack? I understand the benefits of using SAX with regards to performance however, the ease of the XPath syntax seems very appealing.

Thanks so much,
Jay


In reply to Design recommendation for parsing and creating XML files. by jmurphy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.