You are here:  » Multiple Levels with XML file

Support Forum



Multiple Levels with XML file

Submitted by mikebrad0927 on Sun, 2010-01-24 19:48 in

I've seen a similar thread at magicparser.com, but I was wondering if this would be possible with Price Tapestry.

This isn't the exact format but it's an example of what I'm trying to do here. I have an xml file with multiple levels and sub-levels within these levels. Here is the format (in MagicParser-ese):

xml|/SPORT/GROUP/EVENT/TEAM/PLAYER/

There are several sports, each consisting of multiple groups. Within each group, there are multiple events, with multiple teams competing within each event. Naturally, of course, each team has multiple players with stats that I want to parse into my database for comparison later.

I am fairly familiar with xml and php and have been able to do this with my own custom script using "simplexml_load_file" and various foreach loops to go through the different levels. I've hit a brick wall due to the standardization of feeds (there are multiple vendors) and thought of pricetapesty, which I've used in the past successfully, to do this type of thing.

As far as I can tell, I can accomplish exactly what I am trying to do with a few simple hacks to the db structure, which I have already done, AND the ability to select higher-level attributes within the feeds_register_step2.php file, which is where I need your help.

Is this possible?

I want to use xml|/SPORT/GROUP/EVENT/TEAM/PLAYER/ as my format but I want to be able to freely select any level within that structure as possible fields.

If I changed the input to a text field versus a dropdown list, would that work?

Thanks for your help,

Mike

Submitted by support on Mon, 2010-01-25 09:42

Hello Mike,

Unfortunately not i'm afraid - the parser isn't ideally suited (as you've discovered) to nested XML structures. In this instance, it would probably be easier to replicate the sort of field mapping functionality of Price Tapestry into your own application - which is probably less work that adapting Price Tapestry to suit, if that makes sense...

I'm sorry that's not more of a comprehensive answer - I'll take a look at the parser and see what would be involved in capturing and giving access to higher level elements, something like $record["../../TITLE"] as this could come in handy for a number of applications... i'll let you know if that's looking viable - it's something i've had in mind for a while now...

Cheers,
David.

Submitted by mikebrad0927 on Mon, 2010-01-25 17:24

David,

I sort of figured as much and had already started heading down that path. I really enjoy working with PT and had hoped that there may be an easy hack that would allow me to access the higher level elements. If there were, I'd set the script to the lowest element possible and then continue to capture the higher level data over and over again as it cycled through each lower level, if that makes any sense.

Thanks again for all of your help, I'll definitely look at the field mapping and normalizing functions to see if there is something that works for me.