Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #5000
| From | Basewind <mike@pearl-group.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | simplexml adding 'encoding' attribute to xml declaration |
| Date | 2012-02-24 19:17 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <23370133.287.1330139868500.JavaMail.geo-discussion-forums@pbcqw3> (permalink) |
I'm creating an xml file using simplexml, but would like to add the encoding="UTF-8" to the XML declaration. Like this:
<?xml version="1.0" encoding="UTF-8"?>
How can I do this?
Here's my code:
<?php
$namesXML = new SimpleXMLElement("<names></names>");
echo $namesXML->asXML();
This shows:
<?xml version="1.0" ?><!-- want the encoding attribute added here -->
<names/>
Thanks!
Back to comp.lang.php | Previous | Next — Next in thread | Find similar | Unroll thread
simplexml adding 'encoding' attribute to xml declaration Basewind <mike@pearl-group.com> - 2012-02-24 19:17 -0800 Re: simplexml adding 'encoding' attribute to xml declaration Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-25 20:40 +0100 Re: simplexml adding 'encoding' attribute to xml declaration "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-02-27 10:34 +0100
csiph-web