#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    4
    Rep Power
    0

    Processing large xml file with php


    Hi eveyboady,
    I'm new in php/Mysqal and XML.
    I need to read and exctract many and specific information fom a large XML file about (about 3000 lines).
    i need to Retrieve many Elements and Attributes values. then i insert them into database.

    the problem is about how to exctrct over 100 of Elements and Attributes.
    i was thinking about create class(s). what do you think?
    i need this too much please.
    thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,619
    Rep Power
    595
    What is your specific concern?

    There already is a class for XML, it is DOM.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    4
    Rep Power
    0
    hello gw1500se
    thanks for your answer and for your link.
    jo
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    4
    Rep Power
    0
    hello David,
    thank you for you replay.
    i'll explain: first i need to read and extract data from a large xml file (about 3000 lines) which is like this:

    <controle val="U22W0520111">
    for example: i need to extract val,

    then extracting some elements look like this <name>jon</name>

    and so on. the problem is i should extract over 100 elements and values form this large file, also these data can be found in many elements , not only from one part or one node.

    so imagine how many founctions i need to exctract over 100 elements and values attributes,.....

    and after exctracting these values, i musr insert them into mysql database.

    the question is: do you any idea about how i can extract them without needing to repeat the fonction over 100 times for the extraction. i.e create class to extract and insert the values dirctly into database.

    thank you again,
    JO
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,619
    Rep Power
    595
    I'm still not understanding your concern. You don't need any functions. You can loop through the DOM class and build a query with the data on each pass to update the database.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    4
    Rep Power
    0
    can you give me an exemple please?
  12. #7
  13. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,556
    Rep Power
    2338
    Did you bother to read through the manual which was linked to by gw1500se? Here, I'll put it there again:

    PHP manual for DOM

    There's also SimpleXML

    In fact, there is a whole section on XML manipulation.

    You should get reading and actually try to solve this yourself. If you run into problems once you've tried, then come back with specific questions.
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  14. #8
  15. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Originally Posted by ptr2void
    then come back with specific questions.
    To this same point, a brief question is not a specific question. Just because your question is one sentence doesn't make it specific. If you want someone to help you learn how to fly a plane, you don't say "how do you fly a plane?"
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo