Advertisement
Guest User

Untitled

a guest
Sep 8th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. <?php
  2.  
  3. $string = '<a href="google.com/maps">Go to google maps</a> and some special characters ë è & ä etc.';
  4.  
  5. $string = htmlentities($string, ENT_QUOTES, 'UTF-8');
  6.  
  7. $doc = new DOMDocument('1.0', 'UTF-8');
  8. $doc->preserveWhiteSpace = false;
  9. $doc->formatOutput = true;
  10.  
  11. $root = $doc->createElement('top');
  12. $root = $doc->appendChild($root);
  13.  
  14. $title = $doc->createElement('title', $string);
  15. $title = $root->appendChild($title);
  16.  
  17. $id = $doc->createAttribute('id');
  18. $id->value = '1';
  19. $text = $title->appendChild($id);
  20.  
  21. $text = $title->appendChild($text);
  22.  
  23. $doc->save('data.xml');
  24.  
  25. echo 'data saved!';
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement