Re: XML values to database records (grep?)

This WebDNA talk-list message is from

2000


It keeps the original formatting.
numero = 32907
interpreted = N
texte = Damn. I was afraid of that. I am not a perl programmer so I was hoping to keep this in the Webcat realm.Mike> Mike - > > You are not going to be able to do this with a grep, because of the > need to match both starting and ending tags. The variability of the > tags is also going to give you hives. What you really need is a finite > state engine to walk the XML file, which is to say you need a full > fledged parser. If the file only includes a small number of fields (as > below), you might be able to fake something up, but it is really not > something that WebCat is even vaguely designed to handle. > > Perl, on the other hand, could eat this file up and spit is out in any > number of formats (include tab delimited, hint hint). You may want to > check out > > http://www.perlxml.com/faq/perl-xml-faq.html > > for some links that may point you in useful directions. > > John Peacock > > Mike Davis wrote: >> >> I'm trying to parse some values from XML so that they can be appended as >> records into a database. So far I'm stumped as to how to parse this style >> of data using WebDNA. But I have the feeling that someone who is more >> fluent in grep than I (John Peacock hint hint nudge nudge) could see how to >> make this happen. The construct of the XML is listed below. I want to take >> each , treat is as a database record, and append its s to >> the database using the pairs within each . So using >> the example below, I would like to be able to create an [append] context >> like this: >> [append db=x.db] >> channeltitle=NZ Jazz Online - Jazz.co.nz >> &id=75 >> &storytext=<a href=http://jazz.co.nz>Manuel Bundy</a> >> &time=19991004T02:01:13 >> [/append] >> >> Of course, I would like to extrapolate the data into an array of variables >> first so that I could manipulate it (change the date format for instance) >> before I append it to the database. *Note that some s have >> sub-identifiers such as and . >> >> XML: >> snip... >> >> >> >> channeltitle >> NZ Jazz Online - Jazz.co.nz >> >> >> id >> >> 75 >> >> >> >> storytext >> <a href=http://jazz.co.nz>Manuel Bundy</a> >> >> >> time >> >> 19991004T02:01:13 >> >> >> >> >> ...snip >> >> -- This is only one isolated . The entire XML source would have >> many s so my solution will need to recurs through the XML source and >> break each out as an individual record. >> >> Hmmf. Anyone? Ken? John? Grant? >> >> Thanks, >> Mike > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > > Web Archive of this list is at: http://search.smithmicro.com/ ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: XML values to database records (grep?) (Mike Davis 2000)
  2. Re: XML values to database records (grep?) (John Peacock 2000)
  3. XML values to database records (grep?) (Mike Davis 2000)
Damn. I was afraid of that. I am not a perl programmer so I was hoping to keep this in the Webcat realm.Mike> Mike - > > You are not going to be able to do this with a grep, because of the > need to match both starting and ending tags. The variability of the > tags is also going to give you hives. What you really need is a finite > state engine to walk the XML file, which is to say you need a full > fledged parser. If the file only includes a small number of fields (as > below), you might be able to fake something up, but it is really not > something that WebCat is even vaguely designed to handle. > > Perl, on the other hand, could eat this file up and spit is out in any > number of formats (include tab delimited, hint hint). You may want to > check out > > http://www.perlxml.com/faq/perl-xml-faq.html > > for some links that may point you in useful directions. > > John Peacock > > Mike Davis wrote: >> >> I'm trying to parse some values from XML so that they can be appended as >> records into a database. So far I'm stumped as to how to parse this style >> of data using WebDNA. But I have the feeling that someone who is more >> fluent in grep than I (John Peacock hint hint nudge nudge) could see how to >> make this happen. The construct of the XML is listed below. I want to take >> each , treat is as a database record, and append its s to >> the database using the pairs within each . So using >> the example below, I would like to be able to create an [append] context >> like this: >> [append db=x.db] >> channeltitle=NZ Jazz Online - Jazz.co.nz >> &id=75 >> &storytext=<a href=http://jazz.co.nz>Manuel Bundy</a> >> &time=19991004T02:01:13 >> [/append] >> >> Of course, I would like to extrapolate the data into an array of variables >> first so that I could manipulate it (change the date format for instance) >> before I append it to the database. *Note that some s have >> sub-identifiers such as and . >> >> XML: >> snip... >> >> >> >> channeltitle >> NZ Jazz Online - Jazz.co.nz >> >> >> id >> >> 75 >> >> >> >> storytext >> <a href=http://jazz.co.nz>Manuel Bundy</a> >> >> >> time >> >> 19991004T02:01:13 >> >> >> >> >> ...snip >> >> -- This is only one isolated . The entire XML source would have >> many s so my solution will need to recurs through the XML source and >> break each out as an individual record. >> >> Hmmf. Anyone? Ken? John? Grant? >> >> Thanks, >> Mike > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > > Web Archive of this list is at: http://search.smithmicro.com/ ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ Mike Davis

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

WebCatalog 3.0.5b12 helps with cache expiration (1999) WebCat cannot handle compatible search parameters? (1997) Sendmail question (2005) Cookie and Domain Names (2005) Running _every_ page through WebCat-error.html (1997) Authorize.Net (2003) WebDNA Monitor (2005) PCS Frames (1997) search for all (1998) [platform] tag? (1998) authenticating a second user (1997) Multiple Admins through users.db (1997) PCS Emailer's role ? (1997) Up and running ... at last !! (1997) Using Applescript to process WebCatalog functions (1998) $Quit, $CloseDatabase corrections (1997) Proper file locations (1997) Search results templates (1996) Date search - yes or no (1997) tabs as delimiters (2004)