Submitted by globologic on Thu, 2016-05-12 13:03 in Magic Parser
Hi David,
I have a XML file that I get from: {link saved} and I would like to be able to use: xml|EVENTDATA/SPORT/MASTEREVENTS/ but I can't work out how to insert this into a MYSQL table.
That should give you access to all the information you need per event, and when parsing data in this way where multiple parent elements are the same for repeating child elements there is a simple pattern to use whereby you keep a record of the current value of the parent element that you are interested in, and then when it changes process the new data as required; for example (generic)
$currentEventMasterName = "";
function myRecordHandler($record)
{
global $currentEventMasterName;
if ($currentEventMasterName != $record["./EVENTDATA/SPORT/MASTEREVENTS-MASTERNAME"])
{
// process master event here
$currentEventMasterName = $record["./EVENTDATA/SPORT/MASTEREVENTS-MASTERNAME"]
}
}
Hello Jason,
I would suggest using the version of Magic Parser that I forward to you in relation to this thread and parsing at the lowest level, e.g.
xml|EVENTDATA/SPORT/MASTEREVENTS/EVENT/COMPETITOR/
That should give you access to all the information you need per event, and when parsing data in this way where multiple parent elements are the same for repeating child elements there is a simple pattern to use whereby you keep a record of the current value of the parent element that you are interested in, and then when it changes process the new data as required; for example (generic)
$currentEventMasterName = "";
function myRecordHandler($record)
{
global $currentEventMasterName;
if ($currentEventMasterName != $record["./EVENTDATA/SPORT/MASTEREVENTS-MASTERNAME"])
{
// process master event here
$currentEventMasterName = $record["./EVENTDATA/SPORT/MASTEREVENTS-MASTERNAME"]
}
}
Hope this helps!
Cheers,
David
--
MagicParser.com