44    private string $genCmt = 
"Generated by ILIAS XmlWriter";
 
   90        $length = strlen(
$data);
 
   93        for (; $position < $length;) {
 
   94            $character = substr(
$data, $position, 1);
 
   95            $code = Ord($character);
 
   99                    $character = 
""";
 
  103                    $character = 
"&";
 
  107                    $character = 
"'";
 
  120                        $character = (
"&#" . $code . 
";");
 
  125            $escapedData .= $character;
 
  136        if ($this->inEnc == $this->outEnc) {
 
  137            $encodedData = 
$data;
 
  139            switch (strtolower($this->outEnc)) {
 
  141                    if (strtolower($this->inEnc) == 
"iso-8859-1") {
 
  142                        $encodedData = utf8_encode(
$data);
 
  145                            "<b>Error</b>: Cannot encode iso-8859-1 data in " . $this->outEnc .
 
  146                            " in <b>" . __FILE__ . 
"</b> on line <b>" . __LINE__ . 
"</b><br />" 
  152                    if (strtolower($this->inEnc) == 
"utf-8") {
 
  153                        $encodedData = utf8_decode(
$data);
 
  156                            "<b>Error</b>: Cannot encode utf-8 data in " . $this->outEnc .
 
  157                            " in <b>" . __FILE__ . 
"</b> on line <b>" . __LINE__ . 
"</b><br />" 
  164                        "<b>Error</b>: Cannot encode " . $this->inEnc . 
" data in " . $this->outEnc .
 
  165                        " in <b>" . __FILE__ . 
"</b> on line <b>" . __LINE__ . 
"</b><br />" 
  178        $formatedXml = preg_replace_callback(
 
  180            [$this, 
"xmlFormatElement"],
 
  192        $found = trim($array[0]);
 
  199        $tab = str_repeat(
" ", $indent * 2);
 
  202        if (substr($found, 0, 2) == 
"</") {
 
  206            $tab = str_repeat(
" ", $indent * 2);
 
  212            strpos($found, 
"/>") or
 
  213            substr($found, 0, 2) == 
"<!") {
 
  215        } elseif (substr($found, 0, 2) == 
"<?") {
 
  224        if (substr($found, -1) != 
">") {
 
  225            $found = str_replace(
 
  227                ">\n" . str_repeat(
" ", ($indent + 0) * 2),
 
  232        return $nl . $tab . $found;
 
  241        $this->xmlStr .= 
"<?xml version=\"" . $this->version . 
"\" encoding=\"" . $this->outEnc . 
"\"?>";
 
  244        if ($this->dtdDef <> 
"") {
 
  249        if ($this->stSheet <> 
"") {
 
  254        if ($this->genCmt <> 
"") {
 
  264        ?array $attrs = 
null,
 
  270        $this->xmlStr .= 
"<" . $tag;
 
  273        if (is_array($attrs)) {
 
  275            foreach ($attrs as 
$name => $value) {
 
  276                if ($value === 
null) {
 
  290                $this->xmlStr .= 
" " . 
$name . 
"=\"" . $value . 
"\"";
 
  296            $this->xmlStr .= 
"/>";
 
  298            $this->xmlStr .= 
">";
 
  307        $this->xmlStr .= 
"</" . $tag . 
">";
 
  315        $this->xmlStr .= 
"<!--" . 
$comment . 
"-->";
 
  336        $this->xmlStr .= 
$data;
 
  354            $this->xmlStartTag($tag, $attrs, 
false, $encode, $escape);
 
  357            $this->xmlData(
$data, $encode, $escape);
 
  360            $this->xmlEndTag($tag);
 
  363            $this->xmlStartTag($tag, $attrs, 
true, $encode, $escape);
 
  373        if (!($fp = fopen($file, 
"w+"))) {
 
  374            throw new RuntimeException(
 
  375                "<b>Error</b>: Could not open \"" . $file . 
"\" for writing" .
 
  376                " in <b>" . __FILE__ . 
"</b> on line <b>" . __LINE__ . 
"</b><br />" 
  385            $xmlStr = $this->xmlFormatData($this->xmlStr);
 
  387            $xmlStr = $this->xmlStr;
 
  391        fwrite($fp, $xmlStr);
 
  404            $xmlStr = $this->xmlFormatData($this->xmlStr);
 
  406            $xmlStr = $this->xmlStr;
 
  417        $this->xmlStr .= $a_str;
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
xmlSetGenCmt(string $genCmt)
Sets generated comment.
 
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
 
__construct(string $version="1.0", string $outEnc="utf-8", string $inEnc="utf-8")
 
xmlHeader()
Writes xml header.
 
xmlEndTag(string $tag)
Writes an endtag.
 
xmlSetDtdDef(string $dtdDef)
Sets dtd definition.
 
xmlDumpMem(bool $format=true)
Returns xml document from memory.
 
xmlData(string $data, bool $encode=true, bool $escape=true)
Writes data.
 
xmlEscapeData(string $data)
Escapes reserved characters.
 
xmlEncodeData(string $data)
Encodes text from input encoding into output encoding.
 
xmlSetStSheet(string $stSheet)
Sets stylesheet.
 
xmlComment(string $comment)
Writes a comment.
 
xmlFormatElement(array $array)
Callback function for xmlFormatData; do not invoke directly.
 
appendXML(string $a_str)
append xml string to document
 
xmlFormatData(string $data)
Indents text for better reading.
 
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
 
xmlDumpFile(string $file, bool $format=true)
Dumps xml document from memory into a file.
 
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...