By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,871 Members | 2,418 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,871 IT Pros & Developers. It's quick & easy.

PHP and XML

P: 1
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.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $dom = domxml_new_doc('1.0');
  3. $feed = $dom->append_child($dom->create_element("feed"));
  4. $feed->set_attribute('xmlns','http://www.w3.org/2005/Atom');
  5. $feed->set_namespace('http://base.google.com/ns/1.0','g');
  6. $feed->set_namespace('http://linktosite.com/xlink','xlink');
  7.  
  8. foreach(blah as blahh){
  9. $image = "blahblah";
  10. $gimage = $entry->append_child($dom->create_element('g:image_link'));
  11. $gimage->append_child($dom->create_text_node($image));
  12. }
  13. ?>
  14.  
[Please use CODE tags when posting source code. Thanks! --pbmods]

Any help would be wonderful. I'm running out of Valium.
May 25 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.