Skip to content

This is a very easy to use Codeigniter XML writer library I developed to write XLM for communication with a Flash app. But it can be used to generate any well-formed XML document. Works with CI 2+

License

Notifications You must be signed in to change notification settings

oriefrati/xml_writer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XML writer class

Author: Joost van Veen
http://twitter.com/#!/joostvanveen

This is a very easy to use XML writer library I developed to write XLM for communication with a Flash app. But it can be used to generate any well-formed XML document.

It can be used to create any XML, not matter how deep. Every branche and node can have one or more attributes, if needed. Need CDATA? Just set a parameter to true. The library prints XML directly to screen, setting XML headers first, or it can return the XML as a string. Just place the library in applications/library and you’re good to go.

Basically, you can add two types of data:

  • branches – you need to start a new branch and end it before adding the next branch
  • nodes – nodes are children to a branch. You do not have to start and end a node, just add it.

This class Extends XMLWriter (PHP5 only)
You need tot have XMLWriter installed with PHP.
http://php.net/manual/en/book.xmlwriter.php
Important: XMLWriter expects UTF-8 data from you. It can output xml in various encodings, but input should be strictly utf-8!

Installation

  • Simply dump xml_writer.php into library folder.

Manual

  • Follow instructions in xml_writer.php
  • An example can be found in controllers/xml.php

Available methods

These should be pretty self-explanatory. For more info, read docblocks.

  • setRootName ($rootName);
  • setXmlVersion ($version);
  • setCharSet ($charSet);
  • setIndentStr ($indentString);
  • setXsltFilePath ($xsltFilePath);
  • initiate ();
  • startBranch ($name, $attributes = array());
  • endBranch ();
  • addNode ($name, $value, $attributes = array(), $cdata = false);
  • getXml ($echo = false);

Forum thread

http://codeigniter.com/forums/viewthread/108264/

About

This is a very easy to use Codeigniter XML writer library I developed to write XLM for communication with a Flash app. But it can be used to generate any well-formed XML document. Works with CI 2+

Resources

License

Stars

Watchers

Forks

Packages

No packages published