/**
  * Function to load template data from a string instead of a file. e.g. the template is parsed first by php
  * @param unknown_type $str
  */
 public function loadString($str)
 {
     $this->_template_data = new DOMDocument();
     $this->_template_data->preserveWhiteSpace = false;
     $this->_template_data->loadXML($str);
     $this->createRestorePoint();
 }
Example #2
0
 private function ValueToID($key, $value)
 {
     if (is_int($value)) {
         return $value;
     }
     $data = null;
     $x = new DOMDocument();
     $v = null;
     switch (strtolower($key)) {
         case "vo":
             $data = $this->VOs();
             $x->loadXML($data);
             $v = $x->getElementsByTagName("vo");
             break;
         case "country":
             $data = $this->Regional();
             $x->loadXML($data);
             $v = $x->getElementsByTagName("country");
             break;
         default:
             return $value;
             break;
     }
     $c = $v->length;
     for ($i = 0; $i < $v->length; $i++) {
         $vv = strtolower($key) === 'vo' ? $v->item($i)->getAttribute("name") : $v->item($i)->nodeValue;
         if (strtolower($vv) === strtolower($value)) {
             return $v->item($i)->getAttribute("id");
         }
     }
     return $value;
 }
 public function testMarshalling()
 {
     $indexedEndpointType = new SAML2_XML_md_IndexedEndpointType();
     $indexedEndpointType->Binding = 'TestBinding';
     $indexedEndpointType->Location = 'TestLocation';
     $indexedEndpointType->index = 42;
     $indexedEndpointType->isDefault = FALSE;
     $document = new DOMDocument();
     $document->loadXML('<root />');
     $indexedEndpointTypeElement = $indexedEndpointType->toXML($document->firstChild, 'md:Test');
     $indexedEndpointElements = SAML2_Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
     $this->assertCount(1, $indexedEndpointElements);
     $indexedEndpointElement = $indexedEndpointElements[0];
     $this->assertEquals('TestBinding', $indexedEndpointElement->getAttribute('Binding'));
     $this->assertEquals('TestLocation', $indexedEndpointElement->getAttribute('Location'));
     $this->assertEquals('42', $indexedEndpointElement->getAttribute('index'));
     $this->assertEquals('false', $indexedEndpointElement->getAttribute('isDefault'));
     $indexedEndpointType->isDefault = TRUE;
     $document->loadXML('<root />');
     $indexedEndpointTypeElement = $indexedEndpointType->toXML($document->firstChild, 'md:Test');
     $indexedEndpointTypeElement = SAML2_Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
     $this->assertCount(1, $indexedEndpointTypeElement);
     $this->assertEquals('true', $indexedEndpointTypeElement[0]->getAttribute('isDefault'));
     $indexedEndpointType->isDefault = NULL;
     $document->loadXML('<root />');
     $indexedEndpointTypeElement = $indexedEndpointType->toXML($document->firstChild, 'md:Test');
     $indexedEndpointTypeElement = SAML2_Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
     $this->assertCount(1, $indexedEndpointTypeElement);
     $this->assertTrue(!$indexedEndpointTypeElement[0]->hasAttribute('isDefault'));
 }
 public function __toString()
 {
     $string = '';
     $dom = new DOMDocument();
     $dom->preserveWhiteSpace = FALSE;
     $dom->formatOutput = TRUE;
     $string .= '<pre>';
     $string .= 'Exception: ' . $this->getMessage() . '<br><br><br><br>';
     $string .= 'If you think there is a bug in SimpleCalDAV, please report the following information on github or send it at palm.michael@gmx.de.<br><br><br>';
     $string .= '<br>For debugging purposes:<br>';
     $string .= '<br>last request:<br><br>';
     $string .= $this->requestHeader;
     if (!empty($this->requestBody)) {
         if (!preg_match('#^Content-type:.*?text/calendar.*?$#', $this->requestHeader, $matches)) {
             $dom->loadXML($this->requestBody);
             $string .= htmlentities($dom->saveXml());
         } else {
             $string .= htmlentities($this->requestBody) . '<br><br>';
         }
     }
     $string .= '<br>last response:<br><br>';
     $string .= $this->responseHeader;
     if (!empty($this->responseBody)) {
         if (!preg_match('#^Content-type:.*?text/calendar.*?$#', $this->responseHeader, $matches)) {
             $dom->loadXML($this->responseBody);
             $string .= htmlentities($dom->saveXml());
         } else {
             $string .= htmlentities($this->responseBody);
         }
     }
     $string .= '<br><br>';
     $string .= 'Trace:<br><br>' . $this->getTraceAsString();
     $string .= '</pre>';
     return $string;
 }
    public function __construct($name = null, array $data = array(), $dataName = '')
    {
        $this->createdDOMValue = new DOMDocument();
        $this->createdDOMValue->loadXML(<<<EOT
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml" xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom" version="5.0-variant ezpublish-1.0">
    <para><link xlink:href="ezlocation://58" xlink:show="none">link1</link></para>
    <para><link xlink:href="ezcontent://54" xlink:show="none">link2</link> <ezembedinline xlink:href="ezlocation://60" view="embed" xml:id="embed-id-1" ezxhtml:class="embed-class" ezxhtml:align="left"></ezembedinline></para>
</section>
EOT
);
        $this->updatedDOMValue = new DOMDocument();
        $this->updatedDOMValue->loadXML(<<<EOT
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml" xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom" version="5.0-variant ezpublish-1.0">
    <para><link xlink:href="ezlocation://60" xlink:show="none">link1</link></para>
    <para><link xlink:href="ezcontent://56" xlink:show="none">link2</link></para>
    <ezembed xlink:href="ezcontent://54" view="embed" xml:id="embed-id-1" ezxhtml:class="embed-class" ezxhtml:align="left">
      <ezconfig>
        <ezvalue key="size">medium</ezvalue>
        <ezvalue key="offset">10</ezvalue>
        <ezvalue key="limit">5</ezvalue>
      </ezconfig>
    </ezembed>
</section>
EOT
);
        parent::__construct($name, $data, $dataName);
    }
 /**
  * Detects feed types and instantiate appropriate objects.
  *
  * Our constructor takes care of detecting feed types and instantiating
  * appropriate classes. For now we're going to treat Atom 0.3 as Atom 1.0
  * but raise a warning. I do not intend to introduce full support for 
  * Atom 0.3 as it has been deprecated, but others are welcome to.
  *
  * @param    string    $feed    XML serialization of the feed
  * @param    bool    $strict    Whether or not to validate the feed
  * @param    bool    $suppressWarnings Trigger errors for deprecated feed types?
  * @param    bool    $tidy    Whether or not to try and use the tidy library on input
  */
 function build(DOMDocument $model, $feed, $strict = false, $suppressWarnings = false, $tidy = false)
 {
     $options = 0;
     if ($suppressWarnings) {
         $options |= LIBXML_NOWARNING;
         $options |= LIBXML_NOERROR;
     }
     if (empty($feed)) {
         throw new XML_Feed_Parser_Exception('Invalid input: file is empty');
     }
     if (!$model->loadXML($feed, $options)) {
         if (extension_loaded('tidy') && $tidy) {
             $tidy = new tidy();
             $tidy->parseString($feed, array('input-xml' => true, 'output-xml' => true));
             $tidy->cleanRepair();
             if (!$model->loadXML((string) $tidy)) {
                 throw new XML_Feed_Parser_Exception('Invalid input: this is not ' . 'valid XML');
             }
         } else {
             throw new XML_Feed_Parser_Exception('Invalid input: this is not valid XML');
         }
     }
     /* detect feed type */
     $doc_element = $model->documentElement;
     $class = $this->determineClass($doc_element, $suppressWarnings);
     /* Instantiate feed object */
     $feed = new $class($model, $strict);
     $feed->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
     return $feed;
 }
Example #7
0
    public function testUnmarshalling()
    {
        $mdNamespace = SAML2_Const::NS_MD;
        $document = new DOMDocument();
        $document->loadXML(<<<XML
<md:Test xmlns:md="{$mdNamespace}" Binding="urn:something" Location="https://whatever/" xmlns:test="urn:test" test:attr="value" />
XML
);
        $endpointType = new SAML2_XML_md_EndpointType($document->firstChild);
        $this->assertEquals(TRUE, $endpointType->hasAttributeNS('urn:test', 'attr'));
        $this->assertEquals('value', $endpointType->getAttributeNS('urn:test', 'attr'));
        $this->assertEquals(FALSE, $endpointType->hasAttributeNS('urn:test', 'invalid'));
        $this->assertEquals('', $endpointType->getAttributeNS('urn:test', 'invalid'));
        $endpointType->removeAttributeNS('urn:test', 'attr');
        $this->assertEquals(FALSE, $endpointType->hasAttributeNS('urn:test', 'attr'));
        $this->assertEquals('', $endpointType->getAttributeNS('urn:test', 'attr'));
        $endpointType->setAttributeNS('urn:test2', 'test2:attr2', 'value2');
        $this->assertEquals('value2', $endpointType->getAttributeNS('urn:test2', 'attr2'));
        $document->loadXML('<root />');
        $endpointTypeElement = $endpointType->toXML($document->firstChild, 'md:Test');
        $endpointTypeElements = SAML2_Utils::xpQuery($endpointTypeElement, '/root/saml_metadata:Test');
        $this->assertCount(1, $endpointTypeElements);
        $endpointTypeElement = $endpointTypeElements[0];
        $this->assertEquals('value2', $endpointTypeElement->getAttributeNS('urn:test2', 'attr2'));
        $this->assertEquals(FALSE, $endpointTypeElement->hasAttributeNS('urn:test', 'attr'));
    }
    protected function setUp()
    {
        parent::setUp();
        $this->createdDOMValue = new DOMDocument();
        $this->createdDOMValue->loadXML(<<<EOT
<?xml version="1.0" encoding="utf-8"?>
<section xmlns:image="http://ez.no/namespaces/ezpublish3/image/" xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/" xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">
<paragraph>Example</paragraph>
<paragraph><link node_id="58">link1</link></paragraph>
<paragraph><link object_id="54">link2</link></paragraph>
<paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">
    <embed view="embed" size="medium" node_id="60" custom:offset="0" custom:limit="5"/>
    <embed view="embed" size="medium" object_id="56" custom:offset="0" custom:limit="5"/>
</paragraph>
</section>
EOT
);
        $this->updatedDOMValue = new DOMDocument();
        $this->updatedDOMValue->loadXML(<<<EOT
<?xml version="1.0" encoding="utf-8"?>
<section xmlns:image="http://ez.no/namespaces/ezpublish3/image/" xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/" xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">
<paragraph>Example 2</paragraph>
<paragraph><link node_id="60">link1</link></paragraph>
<paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">
    <embed view="embed" size="medium" object_id="56" custom:offset="0" custom:limit="5"/>
</paragraph>
</section>
EOT
);
    }
Example #9
0
 protected function _render($bAdminMode = false)
 {
     $sContent = $this->content;
     if ($bAdminMode) {
         $oTMPDocument = new DOMDocument();
         $oTMPDocument->loadXML('<root>' . str_replace('&', '&amp;', $sContent) . '</root>');
         if ($oTMPDocument->firstChild->childNodes->length == 1 && $oTMPDocument->firstChild->childNodes->item(0)->nodeType == XML_TEXT_NODE) {
             $oTMPDocument->loadXML('<root><p>' . $sContent . '</p></root>');
         }
         foreach ($oTMPDocument->firstChild->childNodes as $oChildNode) {
             if ($oChildNode->nodeType == XML_TEXT_NODE) {
                 continue;
             }
             if ($oChildNode->nodeName == 'div') {
                 $oChildNode->parentNode->removeChild($oChildNode);
                 continue;
             }
             foreach ($this->_oNode->attributes as $oOriginalNodeAttribute) {
                 $oChildNode->setAttribute($oOriginalNodeAttribute->name, $oOriginalNodeAttribute->value);
             }
             // $oChildNode->setAttribute( 'data-brick', $this->ref );
             $oChildNode->setAttribute('data-brick-parsed', 'yes');
             DOMParser::addClassTo('posib-editable', $oChildNode);
         }
         $sContent = null;
         DOMParser::getNodeContent($oTMPDocument->firstChild, $sContent);
     }
     DOMParser::replaceNodeWithContent(str_replace('& ', '&amp; ', $this->_cleanContent($sContent)), $this->_oNode);
 }
Example #10
0
 /**
  * Load XML schema string
  * 
  * @param  string $xmlSchema
  */
 protected function loadSchema($xmlSchema)
 {
     $this->doc = new \DOMDocument();
     $this->doc->loadXML(mb_convert_encoding($xmlSchema, $this->encoding, mb_detect_encoding($xmlSchema)));
     $this->xpath = new \DOMXPath($this->doc);
     $this->xpath->registerNamespace($this->namespacePrefix, $this->xmlSchemaNamespace);
 }
 /**
  * @param string $xml
  *
  * @throws XMLSuggestionException
  */
 public function __construct($xml)
 {
     $this->xml = $xml;
     $this->document = new \DOMDocument();
     if (!@$this->document->loadXML($this->xml)) {
         throw new XMLSuggestionsException('Invalid XML supplied.');
     }
 }
Example #12
0
 /**
  * Constructor
  * @param string $xml XML
  */
 public function __construct($xml, XmlParserFunctions $functions)
 {
     $this->doc = new \DOMDocument();
     if (!@$this->doc->loadXML($xml) || !@($this->xp = new \DOMXPath($this->doc))) {
         throw new \RuntimeException('Error while loading the XML.');
     }
     $this->functions = $functions;
 }
 public function buildXML()
 {
     $utf8Body = utf8_encode($this->body);
     $afterJdm = explode('<code>', $utf8Body);
     $xml = explode('</code>', $afterJdm[1]);
     //echo '<textarea>' . $xml[0] . '</textarea>';
     $this->dom->loadXML(str_replace('<br>', '<br />', $xml[0]));
 }
function xslt_process($xh, $xmlcontainer, $xslcontainer, $resultcontainer = null, $arguments = array(), $parameters = array())
{
    //See also: http://alexandre.alapetite.fr/doc-alex/domxml-php4-php5/
    //Based on: http://www.php.net/manual/ref.xsl.php#45415
    $xml = new DOMDocument();
    $basedir = $xh->getParameter('sablotron', 'xslt_base_dir');
    if ($basedir && ($workdir = getcwd())) {
        chdir($basedir);
    }
    if (substr($xmlcontainer, 0, 5) === 'arg:/') {
        $arg = substr($xmlcontainer, 5);
        if (isset($arguments['/' . $arg])) {
            $xml->loadXML($arguments['/' . $arg]);
        } elseif (isset($arguments[$arg])) {
            $xml->loadXML($arguments[$arg]);
        }
    } else {
        $xml->load($xmlcontainer);
    }
    $xsl = new DOMDocument();
    if (substr($xslcontainer, 0, 5) === 'arg:/') {
        $arg = substr($xslcontainer, 5);
        if (isset($arguments['/' . $arg])) {
            $xsl_ =& $arguments['/' . $arg];
        } elseif (isset($arguments[$arg])) {
            $xsl_ =& $arguments[$arg];
        } else {
            $xsl_ = '';
        }
    } else {
        $xsl_ = file_get_contents($xslcontainer);
    }
    $xsl->loadXML(str_replace('arg:/', 'arg://', $xsl_));
    $xh->importStyleSheet($xsl);
    global $xslArgs;
    $xslArgs = $arguments;
    if ($parameters != null) {
        foreach ($parameters as $param => $value) {
            $xh->setParameter('', $param, $value);
        }
    }
    $result = $xh->transformToXML($xml);
    if (isset($resultcontainer)) {
        if (substr($resultcontainer, 0, 4) === 'arg:') {
            $xslArgs[substr($resultcontainer, 4)] = $result;
        } else {
            file_put_contents($resultcontainer, $result);
        }
    }
    if ($basedir && $workdir) {
        chdir($workdir);
    }
    if (isset($resultcontainer)) {
        return true;
    } else {
        return $result;
    }
}
 public function setXML($xml)
 {
     assert('is_string($xml)');
     $this->dom = new DOMDocument();
     $ok = $this->dom->loadXML(str_replace("\r", "", $xml));
     if (!$ok) {
         throw new Exception('Unable to parse AuthnResponse XML.');
     }
 }
Example #16
0
 /**
  * Initializes a new RichText Value object with $xmlDoc in
  *
  * @param \DOMDocument|string $xml
  */
 public function __construct($xml = null)
 {
     if ($xml instanceof DOMDocument) {
         $this->xml = $xml;
     } else {
         $this->xml = new DOMDocument();
         $this->xml->loadXML($xml === null ? self::EMPTY_VALUE : $xml);
     }
 }
Example #17
0
function GetStockMaat($product_id, $maat, $data)
{
    if (SOAP_SERVER != '') {
        $get_model_query = tep_db_query("select products_model, products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int) $product_id . "'");
        $get_model = tep_db_fetch_array($get_model_query);
        $client = new SoapClient(null, array('location' => SOAP_SERVER, 'uri' => SOAP_NAMESPACE, 'trace' => true, 'connection_timeout' => 5));
        $response = $client->__doRequest('<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
		  <SOAP-ENV:Body>
			<ns1:stockRequest>
			  <Artikel>' . $get_model['products_model'] . '</Artikel>
			  <Maat>' . $maat . '</Maat>
			</ns1:stockRequest>
		  </SOAP-ENV:Body>
		</SOAP-ENV:Envelope>', SOAP_SERVER, SOAP_NAMESPACE, SOAP_1_2);
        if ($response) {
            $dom = new DOMDocument();
            $dom->loadXML($response);
            $xPath = new DOMXPath($dom);
            if ($xPath->evaluate("//Status")->item(0)->nodeValue == 0) {
                $result = $xPath->evaluate("//StatusTekst")->item(0)->nodeValue;
            } else {
                //Article contains XML inside, need to reparse it
                $dom->loadXML('<xml>' . $xPath->evaluate("//Artikel")->item(0)->nodeValue . '</xml>');
                $xPath = new DOMXPath($dom);
                $elements = $xPath->evaluate("//xml/*");
                if ($maat == '') {
                    foreach ($elements as $element) {
                        if ($element->nodeName == 'Maten') {
                            continue;
                        }
                        if ($element->nodeName == $data) {
                            $result .= $element->nodeValue . ' ';
                        }
                    }
                } else {
                    $maats = $xPath->evaluate("//xml/Maten/Maat");
                    if ($maats->length > 0) {
                        foreach ($maats as $maat) {
                            $elements = $xPath->evaluate("child::*", $maat);
                            foreach ($elements as $element) {
                                if ($element->nodeName == $data) {
                                    $result .= $element->nodeValue;
                                }
                            }
                        }
                    }
                }
            }
        } else {
            tep_mail('ABO Service Monitor', '*****@*****.**', 'SOAP Server offline', 'De SOAP Server op ' . STORE_NAME . ' - ' . HTTP_SERVER . ' is offline', STORE_NAME, STORE_OWNER_EMAIL_ADDRESS);
            $result .= $get_model['products_quantity'];
        }
    } else {
        $result = 'No SOAP server defined. Please check configuration';
    }
    return $result;
}
Example #18
0
 /**
  * Sends a request with the secured client, and loads
  * the result response into Service->response
  *
  * An instance of Twinfield\Response\Response is also returned.
  *
  * @since 0.0.1
  *
  * @access public
  * @param Document $document A class that extended Secure\Document
  * @return \DOMDocument The response from the request
  */
 public function send(\DOMDocument $document)
 {
     // Get the secureclient and send this documents xml
     $this->result = $this->login->getClient()->ProcessXmlString(array('xmlRequest' => $document->saveXML()));
     // Make a new DOMDocument, and load the response into it
     $this->response = new \DOMDocument();
     $this->response->loadXML($this->result->ProcessXmlStringResult);
     return new Response($this->response);
 }
Example #19
0
 /**
  * Creates a DOM-Document using the passed string
  *
  * @param string $strString
  *
  * @return bool
  */
 public function loadString($strString)
 {
     $arrModules = get_loaded_extensions();
     if (!in_array("dom", $arrModules)) {
         throw new class_exception("no DOM-Extension installed", class_exception::$level_ERROR);
     }
     $this->objDocument = new DOMDocument();
     return @$this->objDocument->loadXML($strString);
 }
 /**
  * @param $body
  */
 public function buildXML($body)
 {
     $this->body = $body;
     $utf8Body = utf8_encode($this->body);
     $afterJdm = explode('<CODE>', $utf8Body);
     // print_r($afterJdm);
     $xml = explode('</CODE>', $afterJdm[1]);
     //echo '<textarea>' . $xml[0] . '</textarea>';
     $this->dom->loadXML(str_replace('<br>', '<br />', $xml[0]));
 }
 /**
  * Load XML file
  *
  * @param string $filepath
  * @return void
  */
 protected function loadFile($filepath)
 {
     // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
     $previousValueOfEntityLoader = libxml_disable_entity_loader(true);
     $this->xmlDoc = new \DOMDocument('1.0', 'utf-8');
     $this->xmlDoc->loadXML(file_get_contents($filepath));
     libxml_disable_entity_loader($previousValueOfEntityLoader);
     // @TODO: oliver@typo3.org: I guess this is not required here
     $this->xmlDoc->saveXML();
 }
 public function testUnmarshalling()
 {
     $document = new DOMDocument();
     $document->loadXML('<md:AdditionalMetadataLocation xmlns:md="' . SAML2_Const::NS_MD . '"' . ' namespace="TheNamespaceAttribute">LocationText</md:AdditionalMetadataLocation>');
     $additionalMetadataLocation = new SAML2_XML_md_AdditionalMetadataLocation($document->firstChild);
     $this->assertEquals('TheNamespaceAttribute', $additionalMetadataLocation->namespace);
     $this->assertEquals('LocationText', $additionalMetadataLocation->location);
     $document->loadXML('<md:AdditionalMetadataLocation xmlns:md="' . SAML2_Const::NS_MD . '"' . '>LocationText</md:AdditionalMetadataLocation>');
     $this->setExpectedException('Exception', 'Missing namespace attribute on AdditionalMetadataLocation element.');
     new SAML2_XML_md_AdditionalMetadataLocation($document->firstChild);
 }
 /**
  * @param string $XML XML document
  * @return \DomDocument|null XML document
  */
 public function load($XML)
 {
     $document = new \DOMDocument($this->version, $this->encoding);
     $XML = preg_replace('/<\\?xml.{1,} ?>\\n/', '', $XML);
     if ($this->ignoreBlanks) {
         @$document->loadXML($XML, LIBXML_NOBLANKS);
     } else {
         @$document->loadXML($XML);
     }
     return $document;
 }
Example #24
0
 /**
  * Loads a xml string, specifying $path is mandatory to provide detailied error handling.
  * 
  * @param	string		$path
  * @param	string		$xml
  */
 public function loadXML($path, $xml)
 {
     $this->path = $path;
     // load xml document
     $this->document->loadXML($xml);
     // check for errors occured in libxml
     $errors = $this->pollErrors();
     if (!empty($errors)) {
         $this->throwException("XML document '" . $this->path . "' is not valid XML.", $errors);
     }
 }
Example #25
0
 /**
  * 
  * @param string $content
  * @return boolean
  */
 public function matches($content = null)
 {
     if (trim($content) == '') {
         return false;
     }
     libxml_use_internal_errors(true);
     $this->domDocument = new \DOMDocument();
     $this->isParseableXml = $this->domDocument->loadXML($content);
     libxml_use_internal_errors(false);
     return $this->isParseableXml();
 }
 /**
  * Loads the Xcode project from the specified path.
  * @param type $path The path to the xcode project file.
  * @return type DOMDocument
  */
 public function load($path)
 {
     $this->sourcePath = $path;
     $contents = file_get_contents($path);
     $this->tempPath = tempnam(dirname($path), 'temp_');
     file_put_contents($this->tempPath, $contents);
     exec(escapeshellcmd(PLUTIL) . " -convert xml1 " . escapeshellarg($this->tempPath));
     $xml = file_get_contents($this->tempPath);
     $this->dom = new DOMDocument();
     $this->dom->loadXML($xml);
     return $dom;
 }
Example #27
0
 /**
  * @param $rawData
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  */
 public function setRawData($rawData)
 {
     if (1 === preg_match('~Puzzle [0-9]+ does not exist~', $rawData)) {
         throw new \InvalidArgumentException(trim($rawData));
     }
     parent::setRawData($rawData);
     $this->domDocument = new \DOMDocument();
     $this->domDocument->preserveWhiteSpace = false;
     if (false === $this->domDocument->loadXML($this->rawData, LIBXML_NOERROR)) {
         throw new \RuntimeException('failed to parse xml');
     }
     $this->domXPath = new \DOMXPath($this->domDocument);
 }
 /**
  * Charger une configuration.
  * @param string $file Le fichier de configuration.
  */
 public function load($file)
 {
     if (!$this->webos->managers()->get('File')->exists($file)) {
         return false;
     }
     $this->file = $this->webos->managers()->get('File')->get($file);
     $this->domdocument->loadXML($this->file->contents());
     $this->config = array();
     $attributes = $this->domdocument->getElementsByTagName('attribute');
     foreach ($attributes as $attribute) {
         $this->config[$attribute->getAttribute('name')] = $attribute->getAttribute('value');
     }
 }
Example #29
0
 /**
  * Constructor
  *
  * @param string|resource $input The input data.
  *
  * @throws Horde_Kolab_FreeBusy_Exception If the input is invalid.
  */
 public function __construct($input)
 {
     if (is_resource($input)) {
         rewind($input);
         $input = stream_get_contents($input);
     }
     $this->_document = new DOMDocument('1.0', 'UTF-8');
     $this->_document->preserveWhiteSpace = false;
     $this->_document->formatOutput = true;
     $result = @$this->_document->loadXML($input);
     if (!$result || empty($this->_document->documentElement)) {
         throw new Horde_Kolab_FreeBusy_Exception('Invalid OWA input!');
     }
 }
 /**
  * @param string $file Path to file
  * @return \DomDocument|null XML document
  * @throws FileNotFoundException
  */
 public function load($file)
 {
     $document = new \DOMDocument($this->version, $this->encoding);
     if (!file_exists($file)) {
         throw new FileNotFoundException();
     }
     $contents = file_get_contents($file);
     $XML = preg_replace('/<\\?xml.{1,} ?>\\n/', '', $contents);
     if ($this->ignoreBlanks) {
         $document->loadXML($XML, LIBXML_NOBLANKS);
     } else {
         $document->loadXML($XML);
     }
     return $document;
 }