PHP and XML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shiggins
    New Member
    • May 2007
    • 1

    PHP and XML

    I'm creating an xml file from database generated data. Once of the nodes requires a link. I'm using PHP's DOM to generate the file but I'm stuck on how create the xlink and to associate it the required node.

    I thought set_namespace might work, but have to include a product id in the link and I'm not sure how to structure it.

    These first 5 lines get things rolling and the last 2 lines which are in a foreach loop generate the node that needs to have a link to the clients site and to the information stored for the product.

    [code=php]
    <?php
    $dom = domxml_new_doc( '1.0');
    $feed = $dom->append_child($ dom->create_element ("feed"));
    $feed->set_attribute( 'xmlns','http://www.w3.org/2005/Atom');
    $feed->set_namespace( 'http://base.google.com/ns/1.0','g');
    $feed->set_namespace( 'http://linktosite.com/xlink','xlink') ;

    foreach(blah as blahh){
    $image = "blahblah";
    $gimage = $entry->append_child($ dom->create_element ('g:image_link' ));
    $gimage->append_child($ dom->create_text_no de($image));
    }
    ?>
    [/code]

    [Please use CODE tags when posting source code. Thanks! --pbmods]

    Any help would be wonderful. I'm running out of Valium.
Working...