Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplexml utf-8 issues #1003

Open
tablatronix opened this issue Jan 21, 2015 · 1 comment
Open

simplexml utf-8 issues #1003

tablatronix opened this issue Jan 21, 2015 · 1 comment
Labels
Milestone

Comments

@tablatronix
Copy link
Member

We do not save all our xml as utf-8
for example user.xml files
$xml = new SimpleXMLElement('<item></item>');

usually we do
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><item></item>');
for cdata support and utf-8 encoding

I suggest we extend SimpleXmlElement or always use extended and
add wrapper functions to create new xml elements for GS in it.

example usage, not actual

I do not know if its possible to modify the constructor... its final

class myclass extends SimpleXMLElement { 
    static function make($data, $xmlVersion='1.0', $xmlEncoding='ISO-8859-1', $rootName='root'){ 
        $obj=parent::__construct($data); 
        $obj->x=$xmlVersion;
        $obj->e=$xmlEncoding;
        $obj->r=$rootName;

        return $obj;
    } 
}

// or 

class myclass extends SimpleXMLElement {
   public static function getInstance($xmlversion = '1.0', $xmlencoding = 'ISO-8859-1', $rootName='root') {
      return new self("<?xml version='$xmlVersion' encoding='$xmlEncoding'?><$rootName />");
   }
}

I have updated all extended objs, but i missed ones using the native class

@tablatronix tablatronix added this to the 3.3.5 milestone Jan 21, 2015
@tablatronix
Copy link
Member Author

also
simplexml_load_file
simplexml_load_string
accept a classname param

@tablatronix tablatronix modified the milestones: v3.4.0, 3.3.5 Jun 23, 2015
@tablatronix tablatronix modified the milestones: 3.5.0, v3.4.0 Jul 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant