Re: TeraScript-Talk: Retrieving data from XML
Cheers, this seems to do the trick: <@NUMROWS ARRAY='<@ELEMENTVALUE OBJECT="myDom" XPATH="/ppproduct/relateditems/relateditem/title">’> I’m returning a specific value within the data to an array and NUMROWing it. Will have to find a value that all records have. I still think using the count() prarameter on the ‘relateditem’s would be more reliable but can’t work out the syntax. Wayne > On 8 Jan 2016, at 9:06 AM, Robert Shubertwrote: > > Yes, XPATH is a general way of accessing data in a XML document. It has > nothing to do with TeraScript specifically, we just pass your input into > third party tools that return results. > > As for counting, I think the best way to do this is to get the array and then > @NUMROWS it. > > You can get an array of matching elements with @ELEMENTVALUE type=array > > -Original Message- > From: Wayne Irvine [mailto:wa...@byteserve.com.au] > Sent: Thursday, January 07, 2016 1:21 PM > To: TeraScript-Talk@terascript.com > Subject: Re: TeraScript-Talk: Retrieving data from XML > > Cheers Robert, not sure why I have never come across that before in the > manual. > > It seems to do all I want to do, but doesn’t give examples for how to do > things like count(). I’ll look up XPATH in general on Google (assuming it’s a > standard implementation) but would it be possible for you to specify an > example which returns the number of relateditems? > > Wayne > >> On 8 Jan 2016, at 4:48 AM, Robert Shubert wrote: >> >> Wayne, >> >> You need to switch to the XPATH syntax. You can do all of what you are >> looking for with that. >> >> XPOINTER is long dead, and won't be supported in future versions. It's >> important that you switch to XPATH. >> >> Robert >> >> -Original Message- >> From: Wayne Irvine [mailto:wa...@byteserve.com.au] >> Sent: Thursday, January 07, 2016 3:32 AM >> To: TeraScript-Talk@terascript.com >> Subject: TeraScript-Talk: Retrieving data from XML >> >> I’ve been tasked with converting a large static site to dynamic database >> driven CMS. >> >> The first step was downloading all the pages and then converting them to a >> XML structure (see example below). I then load the text file into a DOM and >> can pull out ELEMENTVALUES at will and inject them into tables. >> >> <@ASSIGN NAME="myDom" SCOPE="request" VALUE="<@DOM VALUE='@@datafile'>"> >> >> <@ELEMENTVALUE OBJECT="myDom" ATTRIBUTE+"UID" >> XPOINTER="root().child(1).child(1)”> >> >> Returns 'Dinner Time Mr Wolf’. >> >> Can I refer to this by it’s name instead (UID)? >> >> Also, there are some pages that have repeating fields (one or more >> relateditems). I would like to extract this data and inject it into a >> related table. >> >> I can either got through each of the iterations and insert them individually >> (requires a count of instances), or extract as an array and cycle through >> the array. >> >> Is there a way of extracting the number of instances of a given field in an >> XML DOM? >> >> Is there a way of extracting all instances at once as an array? >> >> Wayne Irvine >> >> Byteserve Pty Ltd >> w: http://www.byteserve.com.au/ >> e: i...@byteserve.com.au >> p: +61 02 9960 6099 >> m: 0409 960 609 >> >> >> >> Dinner Time Mr Wolf >> A traditional playground game that can be used by >> one or more children at a time, measuring approximately 7000mm x >> 3000mm >> >> http://projectplaygrounds.com.au/playground-marking/traditional-games/dinner-time-mr-wolf >> Mr Wolf, traditional Playground game, Feet, >> thermoplastic, playground marking, thermal >> A traditional playground game that can be used by >> one or more children at a time, measuring approximately 7000mm x >> 3000mm >> Project Playgrounds Australia - Dinner Time Mr >> Wolf >> dinner-time-mr-wolf >> Traditional Games >> Dinner Time Mr Wolf" >> href="dinner-time-mr-wolf">Dinner Time Mr Wolf >> MRW1_1d4b061cb18e1df1af78940b6b43f4a9.jpg >> MRW1_b9eeb4ce2e9e34768f77132648731760.jpg >> 1770.00 >> MRW2 >> Thermapply >> 300cm >> 700cm >> 0.00kg >> >> >> >> >> hopscotch >> Hopscotch >> HOP1_2e34efbbc8dec3603114c23b8e245f67 >> Hopscotch >> 34 >> 120 >> >> >> hopscotch-rocket-blue-fins >> Hopscotch Rocket - Blue Fins >> HOP3_07baf173863162a1d671d3fc39940761 >> Hopscotch Rocket - Blue Fins >> 64 >> 120 >> >> >> hopscotch-rocket-red-fins >> Hopscotch Rocket - Red Fins >>
TeraScript-Talk: Retrieving data from XML
I’ve been tasked with converting a large static site to dynamic database driven CMS. The first step was downloading all the pages and then converting them to a XML structure (see example below). I then load the text file into a DOM and can pull out ELEMENTVALUES at will and inject them into tables. <@ASSIGN NAME="myDom" SCOPE="request" VALUE="<@DOM VALUE='@@datafile'>"> <@ELEMENTVALUE OBJECT="myDom" ATTRIBUTE+"UID" XPOINTER="root().child(1).child(1)”> Returns 'Dinner Time Mr Wolf’. Can I refer to this by it’s name instead (UID)? Also, there are some pages that have repeating fields (one or more relateditems). I would like to extract this data and inject it into a related table. I can either got through each of the iterations and insert them individually (requires a count of instances), or extract as an array and cycle through the array. Is there a way of extracting the number of instances of a given field in an XML DOM? Is there a way of extracting all instances at once as an array? Wayne Irvine Byteserve Pty Ltd w: http://www.byteserve.com.au/ e: i...@byteserve.com.au p: +61 02 9960 6099 m: 0409 960 609 Dinner Time Mr Wolf A traditional playground game that can be used by one or more children at a time, measuring approximately 7000mm x 3000mm http://projectplaygrounds.com.au/playground-marking/traditional-games/dinner-time-mr-wolf Mr Wolf, traditional Playground game, Feet, thermoplastic, playground marking, thermal A traditional playground game that can be used by one or more children at a time, measuring approximately 7000mm x 3000mm Project Playgrounds Australia - Dinner Time Mr Wolf dinner-time-mr-wolf Traditional Games Dinner Time Mr Wolf" href="dinner-time-mr-wolf">Dinner Time Mr Wolf MRW1_1d4b061cb18e1df1af78940b6b43f4a9.jpg MRW1_b9eeb4ce2e9e34768f77132648731760.jpg 1770.00 MRW2 Thermapply 300cm 700cm 0.00kg hopscotch Hopscotch HOP1_2e34efbbc8dec3603114c23b8e245f67 Hopscotch 34 120 hopscotch-rocket-blue-fins Hopscotch Rocket - Blue Fins HOP3_07baf173863162a1d671d3fc39940761 Hopscotch Rocket - Blue Fins 64 120 hopscotch-rocket-red-fins Hopscotch Rocket - Red Fins HOP2_26cd42dbcfde0aadc5a4633f31b8945a Hopscotch Rocket - Red Fins 59 120 mr-wolf Mr Wolf MRW1A_fbc5ff63ca013fb60a9ee0cd429a064e Mr Wolf 114 120 hopscotch To unsubscribe from this list, please send an email to lists...@terascript.com with "unsubscribe terascript-talk" in the body.
Re: TeraScript-Talk: Retrieving data from XML
Cheers Robert, not sure why I have never come across that before in the manual. It seems to do all I want to do, but doesn’t give examples for how to do things like count(). I’ll look up XPATH in general on Google (assuming it’s a standard implementation) but would it be possible for you to specify an example which returns the number of relateditems? Wayne > On 8 Jan 2016, at 4:48 AM, Robert Shubertwrote: > > Wayne, > > You need to switch to the XPATH syntax. You can do all of what you are > looking for with that. > > XPOINTER is long dead, and won't be supported in future versions. It's > important that you switch to XPATH. > > Robert > > -Original Message- > From: Wayne Irvine [mailto:wa...@byteserve.com.au] > Sent: Thursday, January 07, 2016 3:32 AM > To: TeraScript-Talk@terascript.com > Subject: TeraScript-Talk: Retrieving data from XML > > I’ve been tasked with converting a large static site to dynamic database > driven CMS. > > The first step was downloading all the pages and then converting them to a > XML structure (see example below). I then load the text file into a DOM and > can pull out ELEMENTVALUES at will and inject them into tables. > > <@ASSIGN NAME="myDom" SCOPE="request" VALUE="<@DOM VALUE='@@datafile'>"> > > <@ELEMENTVALUE OBJECT="myDom" ATTRIBUTE+"UID" > XPOINTER="root().child(1).child(1)”> > > Returns 'Dinner Time Mr Wolf’. > > Can I refer to this by it’s name instead (UID)? > > Also, there are some pages that have repeating fields (one or more > relateditems). I would like to extract this data and inject it into a related > table. > > I can either got through each of the iterations and insert them individually > (requires a count of instances), or extract as an array and cycle through the > array. > > Is there a way of extracting the number of instances of a given field in an > XML DOM? > > Is there a way of extracting all instances at once as an array? > > Wayne Irvine > > Byteserve Pty Ltd > w: http://www.byteserve.com.au/ > e: i...@byteserve.com.au > p: +61 02 9960 6099 > m: 0409 960 609 > > > > Dinner Time Mr Wolf > A traditional playground game that can be used by > one or more children at a time, measuring approximately 7000mm x > 3000mm > > http://projectplaygrounds.com.au/playground-marking/traditional-games/dinner-time-mr-wolf > Mr Wolf, traditional Playground game, Feet, > thermoplastic, playground marking, thermal > A traditional playground game that can be used by > one or more children at a time, measuring approximately 7000mm x > 3000mm > Project Playgrounds Australia - Dinner Time Mr > Wolf > dinner-time-mr-wolf > Traditional Games > Dinner Time Mr Wolf" > href="dinner-time-mr-wolf">Dinner Time Mr Wolf > MRW1_1d4b061cb18e1df1af78940b6b43f4a9.jpg > MRW1_b9eeb4ce2e9e34768f77132648731760.jpg > 1770.00 > MRW2 > Thermapply > 300cm > 700cm > 0.00kg > > > > > hopscotch > Hopscotch > HOP1_2e34efbbc8dec3603114c23b8e245f67 > Hopscotch > 34 > 120 > > > hopscotch-rocket-blue-fins > Hopscotch Rocket - Blue Fins > HOP3_07baf173863162a1d671d3fc39940761 > Hopscotch Rocket - Blue Fins > 64 > 120 > > > hopscotch-rocket-red-fins > Hopscotch Rocket - Red Fins > HOP2_26cd42dbcfde0aadc5a4633f31b8945a > Hopscotch Rocket - Red Fins > 59 > 120 > > > mr-wolf > Mr Wolf > MRW1A_fbc5ff63ca013fb60a9ee0cd429a064e > Mr Wolf > 114 > 120 > > > > hopscotch > > > > > > > > To unsubscribe from this list, please send an email to > lists...@terascript.com with "unsubscribe terascript-talk" in the body. > > > > > > > To unsubscribe from this list, please send an email to > lists...@terascript.com with "unsubscribe terascript-talk" in the body. > Wayne Irvine Byteserve Pty Ltd w: http://www.byteserve.com.au/ e: i...@byteserve.com.au p: +61 02 9960 6099 m: 0409 960 609 To unsubscribe from this list, please send an email to lists...@terascript.com with "unsubscribe terascript-talk" in the body.