Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 12-08-06
morleymouse's Avatar
Super Member
 
Join Date: Aug 2003
Location: Costa Del Sheffield
Posts: 2,752
Thanks: 3
Thanked 10 Times in 6 Posts
morleymouse is an unknown quantity at this point
  xml parser problems

having a few problems with an xml parser if anyones got a bit of time, much appreciated.

basically my script (php) connects to my database, and frm a table each row has an entry which related to an xml file. So one row might by id | xml_file_name

I want to cycle through these rows, parsing each file and echo'ing out the data.

Easy, only thing is my parser seems to get stuck after one, the data seems to get trapped in the parser so each time I just get the same stuff echo'ed out.

not sure if theres any easy way to clean the parser out or something after each cycle? bits and bobs of code below, help is much appreciated



Im using a while loop to go through all the records, inside the loop I have...

PHP Code:
$parser xml_parser_create("UTF-8");
xml_set_element_handler($parser"xmlStartTag""xmlEndTag");
xml_set_character_data_handler($parser"xmlCDATA");
xml_parse($parser,$xml,true);

foreach(
$records as $data) {
echo 
$data["NAME"];
}

xml_parser_free($parser); 
outside the loop i've got the rest of the parser...

PHP Code:
function xmlStartTag($parser$name$attribs)
{
  global 
$currentRecord;
  global 
$currentTag;
  global 
$inRecord;
  if (
$name == "TAGNAME")
  {
    
$inRecord true;
    
$currentRecord = array();
  }
  if (
$inRecord)
  {
    
$currentTag $name;
  }
}

function 
xmlCDATA($parser$cdata)
{
  global 
$currentRecord;
  global 
$currentTag;
  
$currentRecord[$currentTag] .= $cdata;
}

function 
xmlEndTag($parser$name)
{
  global 
$records;
  global 
$currentRecord;
  global 
$inRecord;
  if (
$name == "TAGNAME")
  {
    
$inRecord false;
    
$records[] = $currentRecord;
  }

__________________
Dan Morley
Alpharooms.com
daniel at alpharooms dot com - Hotels, Flights, Airport Transfers, Care Hire + More! sign up
My Blog | Cheap Holidays
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 13-08-06
Registered User
 
Join Date: Feb 2006
Location: Gillingham
Posts: 503
Thanks: 0
Thanked 0 Times in 0 Posts
Donk is an unknown quantity at this point
I'm up in Glasgow for a few days so I haven't got too much access to a computer but I've worked out a solution for a site that I have been working on you may find the code there useful. I've sent the url by pm

Bob
__________________
They came for my 404 and I said nothing
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 29-08-06
0111000001110010011010010
 
Join Date: Jan 2005
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
JohnC is an unknown quantity at this point
not sure if this will be much help but theres http://whoooop.co.uk/2005/03/20/xml-to-array/
from my website that might be of some use
__________________
John C
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 30-08-06
morleymouse's Avatar
Super Member
 
Join Date: Aug 2003
Location: Costa Del Sheffield
Posts: 2,752
Thanks: 3
Thanked 10 Times in 6 Posts
morleymouse is an unknown quantity at this point
cheers John, got it all sorted in the end
__________________
Dan Morley
Alpharooms.com
daniel at alpharooms dot com - Hotels, Flights, Airport Transfers, Care Hire + More! sign up
My Blog | Cheap Holidays
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
stumped by xml, again morleymouse Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 5 28-05-06 05:00 PM
bit of a pickle, php xml parser morleymouse Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 5 20-01-06 02:52 PM
Anyone anygood with xml, php, mysql and Affiliate Window AnnonnyMouse The Affiliate Marketing Lounge 1 23-09-04 11:00 AM
Transforming TD XML feeds with a stylesheet in PHP Andy TradeDoubler 0 12-08-04 03:32 PM
PHP XML Parser morleymouse Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 3 15-12-03 11:06 PM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7