How to Get the Position of XML Nodes in a Message

A PHP loop procedure lets you go through each XML node and retrieve its value. Using the loop procedure, you can identify the position of a node in the list of values you have stored in the XML file. The integer value you set up in the loop structure tells you the location of the node in the file.


    • 1

      Right-click the PHP page you want to use to loop through the XML files. Click "Open With" and select your preferred PHP editor.

    • 2

      Get the list of XML nodes from the file you want to import. The following code opens the XML file:


      Replace "customers.xml" with your own XML file.

    • 3

      Loop through each XML node. The following code loops through the nodes and the "i" variable contains the position of each node:

      for (int i = 0; i < doc.nodes.count; i++ )
      nodelocation = i

Related Searches


Related Ads

Check It Out

Prep for Black Friday Checklist [Infographic]