Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Populate dropdown list from xml file?
3stripe
✭✭
Does anyone know how to do this via php? (Can only find .NET examples so far)
0
This discussion has been closed.
Comments
// An empty shell for housing an xml response. class XMLResponse {} function ParseXmlFile($FileLocation) { $Lines = file($FileLocation); $XML = new XMLResponse(); // Loop through each of the lines of the response and get the // properties/values for ($i = 0; $i < count($Lines); $i++) { $Matches = false; preg_match("/(<([^<>\s]*)(\s[^<>]*)?>)(.+?)(<([^<>\s]*)(\s[^<>]*)?>)/", $Lines[$i], $Matches); if (count($Matches) == 7) { $Property = $Matches[2]; $Value = $Matches[4]; $XML->$Property = $Value; } } return $XML; } } /* Assuming the xml file contains something like this: <root> <status>ok</status> <id>123456</id> <username>marky</username> </root> */ $MyXml = ParseXmlFile("/path/to/my/xml/file.xml"); echo($MyXml->username." has an id of ".$MyXml->id." and has a status of ".$MyXml->status); /* Will Print: marky has an id of 123456 and has a status of ok */
<?xml version="1.0" encoding="UTF-8"?> <gallery> <album id="flowers" title="" description="Photos of flowers"> /> </album> <album id="cars" title="" description="Photos of cars"> /> </album> <album id="animals" title="" description="Photos of erm, animals"> /> </album> </gallery>