SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2011
    0 Post(s)
    0 Thread(s)

    xmlReader loop concerns / stackable multiple XMLs?

    PHP version 5.3.21 MySQL version 5.1.70-cll

    Note: I have posted on other forums but not getting any response so Im posting here in hopes of some feed back...

    I have to compile an item catalog within mysql based on a large data feed that requires multiple calls to URLS that build on eachother in order to collect all the catalog data from the remote feed server.

    I have been working with cURL and simpleXML and I have all my code written but it keeps timing out so I guess I have to look at xmlReader which I have never worked with. I have done several hours of research on xmlReader now but I have some concerns.

    can someone please tell me - before I commit to xmlReader - if it can handle this and if xmlReader would be a wise choice in my case - Im mainly concerned about the nested loops here and having to call different URLS within each loop.

    My psuedocode:

    Open Reader
     Open datafeed URL
      Get list of Manufacturer ids using URL =
        For each Manufacturer ID as $xx
          *new reader object? Get list of Models ids using$xx
            Foreach Model ID as $yy
               * new reader object? Get list of Products using URL$xx?ModelID=$yy
                  Foreach Product
                   enter product attributes into mySQL....
                  Close foreach product
            Close foreach model ID
        Close for each Manufacturer
    Close Reader
    So Im just not sure if I close reader and re open with each new URL? I have not seen any examples of folks using foreach with xmlReader... Im concerned that I cant pull this off with xmlReader. Is there another option that would not exhaust my memory.

    Thanks for any advice.

  2. #2
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    45 Post(s)
    13 Thread(s)
    Hi makenoiz,

    I don't think you can use for..each loops with XMLReader, but you can use a while loop and test to find the elements you need. This SPF thread has some code examples using XMLReader that you might find useful (check the code in the last few posts).

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts