How to Assign XML to a Variable in PHP

Hypertext Preprocessor (PHP) is a scripting language used for developing and creating dynamic Web pages with images and interactive elements. It is offered free of charge under the PHP license and can be used on most Web servers as well as operating systems. Extensible Markup Language (XML) is used for storing data in an organized way that most operating systems can understand. You can attach an XML file to a variable on your Web site with a simple PHP script.

Instructions

    • 1

      Click "Start," "All Programs" and "Notepad" to open the text-editing application. Click "File" and "New" to create a new PHP file.

    • 2

      Type "<?php" and "?>" to use as the starting and end tags. Place your XML file between these tags.

    • 3

      Type "simplexml_load_file()" to assign the XML file to a variable. Replace "simplexml" with the name of the variable and fill the parentheses with the XML file name. For example, if the variable is named "$superxmlfile" and the name of the XML file is "launch.xml," you should type "$superxmlfile_load_file(launch.xml)."

    • 4

      Click "File" and "Save As." Save your file as a ".Php" file. Name your file and click "Save." Upload your file to your PHP server to use it.

Related Searches:

References

Comments

Related Ads

Featured