Joined: Jun 30, 2006
Post Subject: php and their incredible xml support...
Posted on: Jul 23, 2008
Now I havne't done a whole ton of xml interaction in the past, just some pretty simple stuff. I'm working on a script that I want to be pretty generic in it's functionality. Thats actually a bit misleading because I want it to work identically on any xml file I read in. I'm looking to have a script that will read an xml file and return a 2D array of values. For example, if I read this xml snippet...
<?xml version="1.0" encoding="utf-8"?>
Currently I'm able to receive my 2d array structured like the below, but I have to create a parsing object specific to the format, and I'm unable to get a generic format. If anyone has a php script designed to map the xml tree structure, that is exactly what I'd need to make this a true universal script.
$array = array("catID" => 0, "display" => "Restaurants")
$array = array("catID" => 1, "display" => "Clothing")
and so on...
The problem I'm currently having is with the parsing. I'm at the point that I'm ready to say, "screw php's native support" and just build my own. I'm able to get the tags in the ITEM tag, but not in any well structured function. This is where I get my problems. I created a parser object and while it wouldn't be a very big deal, I'd have to have to make a near duplicate for each xml file I plan to read in.
This isn't for the site so I can post my work in progress code if anyone needs to see where I'm at currently on this.
With that said if anyone has any ideas I'd be more then open to hear them.
lol currently I have the script built to the point that all you need to do is designate the database info and a table name, and an xml file name and it'll automatically put everything into a very clean formatted xml page. The problem now is getting it out in a universal method now.
If con is the opposite of pro, is Congress the opposite of progress?