willpower Posted October 3, 2007 Share Posted October 3, 2007 PHP5 installed I have an XML file with hundreds of jobs included within it. The task is simple but I have no idea about how to start. Lets say that I want to search for all jobs that have a Live Status. the xml will contain something like <Job> <Job_Number>1245356</Job_Number> <Status>LIVE</Status> <NextField>somedata</NextField> <NextField>somedata</NextField> <NextField>somedata</NextField> and so on </Job> How do I do this a) to return all the nodes which their is a match and b) to retuen only one node upon a match such as Job Number Thanks Will Quote Link to comment Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 Do you know about PHP's XML parsing functions? I haven't ever used them, but they're in the manual for your perusal. Quote Link to comment Share on other sites More sharing options...
willpower Posted October 3, 2007 Author Share Posted October 3, 2007 yeah, i cant seem to find a way of searching through to find a string etc as i would using a DB Quote Link to comment Share on other sites More sharing options...
Barand Posted October 4, 2007 Share Posted October 4, 2007 Have a look at the simplexml functions Quote Link to comment Share on other sites More sharing options...
willpower Posted October 4, 2007 Author Share Posted October 4, 2007 I think this is my fault. I have read those already...and that is where i am stuck tbh. I guess I am not trying to search, but rather 'query' the XML I am capable of parsing each element at will, but I need to look inside the element and see if it meets a given criteria. Hope that makes more sense. So far I have yet to determine such a function Quote Link to comment Share on other sites More sharing options...
jscix Posted October 4, 2007 Share Posted October 4, 2007 You have to loop through each element and examine the field in question. If the field matches 'live', then you extract the required information from that entry. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.