Not signed in (Sign In)

Categories

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

Help keep Vanilla free:
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    •  
      CommentAuthor3stripe
    • CommentTimeJan 6th 2006 edited
     # 1
    Does anyone know how to do this via php? (Can only find .NET examples so far)
    • CommentAuthorSirNot
    • CommentTimeJan 6th 2006 edited
     # 2
    Couldn't you just parse the XML file then generate the HTML accordingly?
    •  
      CommentAuthor3stripe
    • CommentTimeJan 6th 2006
     # 3
    Hmmm maybe, looks complicated though :-?
    •  
      CommentAuthor3stripe
    • CommentTimeJan 6th 2006
     # 4
    Found something at Kirupa that might do the trick: http://www.kirupa.com/web/xml_php_parse_intermediate.htm
    •  
      CommentAuthorMark
    • CommentTimeJan 6th 2006
     # 5
    I recently wrote a little function that parses an xml file one-level deep and returns an object with property->value pairs:

    // 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
    */
    •  
      CommentAuthorBergamot
    • CommentTimeJan 6th 2006
     # 6
    Does the XML have to be in any specific format?

    if not, it could literally be a textdump of the option tags you need, provided it conformed to xml rules.
    •  
      CommentAuthor3stripe
    • CommentTimeJan 6th 2006 edited
     # 7
    The XML is coming from a http://www.slideshowpro.net/ config file which has to go something like this:

    <?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>
    •  
      CommentAuthor3stripe
    • CommentTimeJan 6th 2006
     # 8
    PS. Once I've got this working I need to somehow turn it into a Wordpress extension so that you can automatically insert a link into a post that points to one of the album ids. But that's a post for the Wordpress forum methinks!
Add your comments
    Username Password
  • Format comments as