Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $string = '<a href="google.com/maps">Go to google maps</a> and some special characters ë è & ä etc.';
- $string = htmlentities($string, ENT_QUOTES, 'UTF-8');
- $doc = new DOMDocument('1.0', 'UTF-8');
- $doc->preserveWhiteSpace = false;
- $doc->formatOutput = true;
- $root = $doc->createElement('top');
- $root = $doc->appendChild($root);
- $title = $doc->createElement('title', $string);
- $title = $root->appendChild($title);
- $id = $doc->createAttribute('id');
- $id->value = '1';
- $text = $title->appendChild($id);
- $text = $title->appendChild($text);
- $doc->save('data.xml');
- echo 'data saved!';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement