I have an XML file like this
<varname>varvalue</varname>
saved as filename.xml
How would I get the all of the varnames into variables in PHP?
Thanks
| SitePoint Sponsor |
I have an XML file like this
<varname>varvalue</varname>
saved as filename.xml
How would I get the all of the varnames into variables in PHP?
Thanks
This is probably not a valid xml file.
You should have only one root element in the xml file, then under the root you can put all your varname elements.
Then just use SimpleXML to parse your file.
look at this page:
http://us.php.net/manual/en/function...-load-file.php
It's hard to write an example because I don't know all the details, for example. do you know in advance which varnames you will have in the xml?
It's pretty simple either way.
so probably like this:
<variables>
<varname>text text</varname>
<varname1>text text</varname1>
</variables>
That helped I read through that link you gave me and looks like PHP has some sweet XML reading functions I did this
$variables=simplexml_load_file('variables.xml');
echo 'Variable One: ' . $variables->varname;
and that will do exactly what I need,
Thanks for the help!
Bookmarks