Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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,

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

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2023-09-27 07:54 GMT
Find Nodes?
    Voting Booth?

    No recent polls found