473,466 Members | 1,430 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to parse nested xml into php?

semanticnotion
66 New Member
Hi all i have an xml file e.g
Expand|Select|Wrap|Line Numbers
  1. <recipe>
  2. <id>abc</id>
  3. <name>abc</name>
  4. <instructions>
  5. <instruction>
  6. <id>abc</id>
  7. <text>abc</text>
  8. </instruction>
  9. <instruction>
  10. <id>abc2</id>
  11. <text>abc2<text>
  12. <instruction>
  13. <instructions>
  14. <recipe>
on my php file i use

Expand|Select|Wrap|Line Numbers
  1. $url = "cafe.xml";
  2. // get xml file contents
  3. $xml = simplexml_load_file($url);
  4.  
  5. // loop begins
  6. foreach($xml->recipe as $recipe)
  7. {
  8. code;
  9. }
but it only retrieve the recipe id and name so how can i retrieve the instructions.
Nov 22 '10 #1
6 2508
Claire Julia
1 New Member
you need to use Xpath.
Nov 22 '10 #2
Dormilich
8,658 Recognized Expert Moderator Expert
but it only retrieve the recipe id and name so how can i retrieve the instructions.
I doubt that statement.

unless you have the same XML errors in your original code, all is retrieved properly. you would be able to get the <instructions> element. depending on what you want exactly, an XPath expression might be faster.
Nov 22 '10 #3
semanticnotion
66 New Member
Thanks Dormilich for your reply now i solved the thread read the .xml successfully in php file but now my question is how can i read the client request(web service request) and update the data accordingly in php file.
Nov 23 '10 #4
Dormilich
8,658 Recognized Expert Moderator Expert
how you read the client request depends on its nature (SOAP, XML-RPC, etc.)
Nov 23 '10 #5
semanticnotion
66 New Member
which one is best SOAP or XML-RPC
and would you like to share some useful tutorial about the best one cause i have no idea.
Nov 23 '10 #6
Dormilich
8,658 Recognized Expert Moderator Expert
I have no idea what is best.
Nov 23 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Gregory Nans | last post by:
hello, i need some help to 'tree-ify' a string... for example i have strings such as : s = """A(here 's , B(A ) silly test) C(to show D(what kind) of stuff i need))""" and i need to...
0
by: peter greaves | last post by:
hi everyone i am having a bad time with an entity resolver. my application uses a resolver to locally-cache the nested schemas that the basic xsd includes to a local directory. however i am...
2
by: SEB | last post by:
can any one please redirect me to how to use control builder class to parse the following case (or any other method) <mycustomcontroltag> <item attribute1="x" attribute2="y" ......> <subitems>...
5
by: BMeyer | last post by:
I have been losing my mind trying to parse an XML document (with nested child elements, not all of which appear in each parent node) into a DataGrid object. What I want to do is "flatten" the XML...
4
by: LW | last post by:
Hi! I have a DataSet and a class in my Web Service. My output for example is: <OrderInfo> <CustomerID>VINET</CustomerID> <OrderID>10248</OrderID> <OrderDate>07/07/1996</OrderDate>...
2
by: Ultrus | last post by:
Hello all, I don't need specific examples, but I'm trying to wrap my head around parsing xml within xml and even further, not limiting how far someone will nest xml. I'm already making great use...
36
by: rhys | last post by:
My Gurus and Angels -- Please pardon this old-school programmer, only recently enlightened to open-source, having been trapped in the convenience of proprietary lingos for way too long. My...
5
by: tool69 | last post by:
Hi, I need to parse some source with nested parenthesis, like this : { {item1} { {item2} {item3}
8
by: Sheldon | last post by:
Hi, Can anyone help with this problem with setting up nested structures and initializing them for use. I have created several structs and placed them in a super struct that I will then pass to...
9
by: Adam Nielsen | last post by:
Hi all, I'm a bit confused about the syntax used to access a nested template class. Essentially I have a bunch of class types to represent different types of records in a database, and I want...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.