109 if (is_resource(
$input)) {
119 $rootElementName =
$result[
'name'];
145 if (is_resource(
$input)) {
154 $rootElementName = (array)$rootElementName;
156 foreach ($rootElementName as &$rEl) {
157 if ($rEl[0] !==
'{') $rEl =
'{}' . $rEl;
161 if (!in_array(
$result[
'name'], $rootElementName,
true)) {
162 throw new ParseException(
'Expected ' . implode(
' or ', (array)$rootElementName) .
' but received ' .
$result[
'name'] .
' as the root element');
193 $w->writeElement($rootElementName, $value);
194 return $w->outputMemory();
227 list(
$namespace) = self::parseClarkNotation($elementName);
232 $this->classMap[$className] =
function(
Writer $writer, $valueObject) use (
$namespace) {
235 $this->valueObjectMap[$className] = $elementName;
253 if (!isset($this->valueObjectMap[get_class($object)])) {
254 throw new \InvalidArgumentException(
'"' . get_class($object) .
'" is not a registered value object class. Register your class with mapValueObject.');
257 $this->valueObjectMap[get_class($object)],
277 if (!isset($cache[$str])) {
279 if (!preg_match(
'/^{([^}]*)}(.*)$/', $str, $matches)) {
280 throw new \InvalidArgumentException(
'\'' . $str .
'\' is not
a valid clark-notation formatted
string'); 295 protected $valueObjectMap = []; if($err=$client->getError()) $namespace
This is a base exception for any exception related to parsing xml files.
write($rootElementName, $value, $contextUri=null)
Generates an XML document in one go.
writeValueObject($object, $contextUri=null)
Writes a value object.
mapValueObject($elementName, $className)
Map an xml element to a PHP class.
static parseClarkNotation($str)
Parses a clark-notation string, and returns the namespace and element name components.
The Reader class expands upon PHP's built-in XMLReader.
getWriter()
Returns a fresh xml writer.
expect($rootElementName, $input, $contextUri=null)
Parses a document in full, and specify what the expected root element name is.
XML parsing and writing service.
parse($input, $contextUri=null, &$rootElementName=null)
Parses a document in full.
valueObject(Reader $reader, $className, $namespace)
The valueObject deserializer turns an xml element into a PHP object of a specific class...
getReader()
Returns a fresh XML Reader.