当前位置: 首页>>代码示例>>PHP>>正文


PHP dom_import_simplexml函数代码示例

本文整理汇总了PHP中dom_import_simplexml函数的典型用法代码示例。如果您正苦于以下问题:PHP dom_import_simplexml函数的具体用法?PHP dom_import_simplexml怎么用?PHP dom_import_simplexml使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dom_import_simplexml函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addProcessingInstruction

 public function addProcessingInstruction($target, $data = NULL)
 {
     $node = dom_import_simplexml($this);
     $pi = $node->ownerDocument->createProcessingInstruction($target, $data);
     $result = $node->insertBefore($pi, $node->childNodes->item(0));
     return $this;
 }
开发者ID:shep1990,项目名称:web-project,代码行数:7,代码来源:MySimpleXMLElement.php

示例2: addChild

 /**
  * Add a child element; this corrects CDATA issues
  *
  * @throws RuntimeException
  */
 public function addChild($name, $value = NULL, $namespace = NULL)
 {
     if ($this->isCData($value) || $this->getConfig('autoCData', FALSE) && $this->wrapCData($value)) {
         // Stash a CDATA value for later...
         $valueAsCData = $value;
         $value = NULL;
     } elseif ($this->getConfig('autoEntities', FALSE)) {
         $this->xmlChars($value);
     }
     $child = parent::addChild($name, $value, $namespace);
     // switch (func_num_args()) {
     //   case 1:
     //     $child = parent::addChild($name);
     //     break;
     //   case 2:
     //     $child = parent::addChild($name, $value);
     //     break;
     //   case 3:
     //     $child = parent::addChild($name, $value, $namespace);
     //     break;
     // }
     if (isset($valueAsCData)) {
         $node = dom_import_simplexml($child);
         $no = $node->ownerDocument;
         $value = self::stripCData($valueAsCData);
         $node->appendChild($no->createCDATASection($value));
     }
     return $child;
 }
开发者ID:aklump,项目名称:collection_json,代码行数:34,代码来源:LoftXmlElement.php

示例3: render

 /**
  * Render a Zend_Config into a XML config string.
  *
  * @since 1.10
  * @return string
  */
 public function render()
 {
     $xml = new SimpleXMLElement('<zend-config xmlns:zf="' . Zend_Config_Xml::XML_NAMESPACE . '"/>');
     $extends = $this->_config->getExtends();
     $sectionName = $this->_config->getSectionName();
     if (is_string($sectionName)) {
         $child = $xml->addChild($sectionName);
         $this->_addBranch($this->_config, $child, $xml);
     } else {
         foreach ($this->_config as $sectionName => $data) {
             if (!$data instanceof Zend_Config) {
                 $xml->addChild($sectionName, (string) $data);
             } else {
                 $child = $xml->addChild($sectionName);
                 if (isset($extends[$sectionName])) {
                     $child->addAttribute('zf:extends', $extends[$sectionName], Zend_Config_Xml::XML_NAMESPACE);
                 }
                 $this->_addBranch($data, $child, $xml);
             }
         }
     }
     $dom = dom_import_simplexml($xml)->ownerDocument;
     $dom->formatOutput = true;
     $xmlString = $dom->saveXML();
     return $xmlString;
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:32,代码来源:Xml.php

示例4: prettyPrint

 public static function prettyPrint($data, $rootNodeName = 'data')
 {
     $xml = self::_recursiveXmlEncode($data, $rootNodeName);
     $dom = dom_import_simplexml($xml)->ownerDocument;
     $dom->formatOutput = true;
     return $dom->saveXML();
 }
开发者ID:massimozappino,项目名称:zmz,代码行数:7,代码来源:Xml.php

示例5: replaceChildNode

 private function replaceChildNode(SimpleXMLElement $target, SimpleXMLElement $replacement)
 {
     $target_dom = dom_import_simplexml($target);
     $replacement_dom = $target_dom->ownerDocument->importNode(dom_import_simplexml($replacement), true);
     $p = $target_dom->parentNode;
     return $p->replaceChild($replacement_dom, $target_dom);
 }
开发者ID:virginiarcruz,项目名称:xerteonlinetoolkits,代码行数:7,代码来源:xwdBuilder.php

示例6: saveAction

 public function saveAction()
 {
     $filepath = Mage::getBaseDir("skin") . DS . "frontend" . DS . "default" . DS . "default" . DS . "css" . DS . 'option.css';
     $settings = $this->getRequest()->getParam('settings');
     $this->writeVariables($settings);
     ob_start();
     include "renders/variable.php";
     include "renders/css.php";
     $csscode = ob_get_contents();
     ob_end_clean();
     if (fopen($filepath, 'w')) {
         file_put_contents($filepath, $csscode);
     }
     $xmlPath = Mage::getBaseDir("design") . DS . "frontend" . DS . "base" . DS . "default" . DS . "layout" . DS . 'jmbasetheme.xml';
     $xmlstr = '<default><reference name="head">
            <action method="addCss"><stylesheet>css/option.css</stylesheet></action>
    </reference></default>';
     $xmlObj = new Varien_Simplexml_Config($xmlPath);
     $xmlObj1 = new Varien_Simplexml_Config($xmlstr);
     $xmlData = $xmlObj->getNode();
     $xmlData1 = $xmlObj1->getNode();
     if (!$xmlData->descend("default/reference@name=head")) {
         $reference = $xmlData->appendChild($xmlData1);
         file_put_contents($xmlPath, $xmlData->asNiceXml());
     } else {
         $oNode = dom_import_simplexml($xmlData->default);
         $oNode->parentNode->removeChild($oNode);
         file_put_contents($xmlPath, $xmlData->asNiceXml());
     }
     $this->_redirect('*/*/');
 }
开发者ID:xiaoguizhidao,项目名称:autotech_design,代码行数:31,代码来源:JmbasethemebackendController.php

示例7: testLastChild

 public function testLastChild()
 {
     $root = new SimpleDOM('<root><child1 /><child2 /><child3 /></root>');
     $child2 = $root->child3->previousSibling();
     $this->assertTrue($child2 instanceof SimpleDOM);
     $this->assertSame(dom_import_simplexml($root->child2), dom_import_simplexml($child2));
 }
开发者ID:laiello,项目名称:simpledom,代码行数:7,代码来源:previousSibling.php

示例8: addNodeToParent

 public function addNodeToParent(\SimpleXMLElement $xmlNode, $parent)
 {
     $domNode = dom_import_simplexml($xmlNode);
     $node = $this->xmlDocument->importNode($domNode, TRUE);
     $parentElement = $this->xmlDocument->getElementsByTagName($parent);
     $parentElement->item(0)->appendChild($node);
 }
开发者ID:no-chris,项目名称:connector,代码行数:7,代码来源:XmlDocument.php

示例9: testGrandchild

 public function testGrandchild()
 {
     $root = new SimpleDOM('<root><child><grandchild /></child></root>');
     $parent = $root->child->grandchild->parentNode();
     $this->assertTrue($parent instanceof SimpleDOM);
     $this->assertSame(dom_import_simplexml($root->child), dom_import_simplexml($parent));
 }
开发者ID:laiello,项目名称:simpledom,代码行数:7,代码来源:parentNode.php

示例10: testIsChainable

 public function testIsChainable()
 {
     $node = new SimpleDOM('<node />');
     $return = $node->setAttributes(array());
     $this->assertEquals($node, $return);
     $this->assertTrue(dom_import_simplexml($node)->isSameNode(dom_import_simplexml($return)));
 }
开发者ID:laiello,项目名称:simpledom,代码行数:7,代码来源:setAttributes.php

示例11: analyzeSchematronIssues

function analyzeSchematronIssues($SchematronIssuesReport)
{
    //$schematronIssue = array(new SchematronIssues);
    $reportStartString = "<svrl:failed-assert";
    $reportEndString = "</svrl:failed-assert>";
    $schematronIssue[0]->text = "";
    $schematronIssue[0]->location = "";
    $schematronIssue[0]->attributes = "";
    $reportXML = extractStringBetweenTokens($SchematronIssuesReport, $reportStartString, $reportEndString);
    $reportXML = str_replace("svrl:", "", $reportXML);
    $reportXML = str_replace("failed-assert", "assert", $reportXML);
    $reportXML = "<repots>" . $reportXML . "</repots>";
    $sxe = simplexml_load_string($reportXML);
    $dom_sxe = new DOMDocument('1.0');
    $dom_sxe = dom_import_simplexml($sxe);
    $numErrors = sizeof($sxe);
    for ($i = 0; $i < $numErrors; $i++) {
        $errorElement = $dom_sxe->getElementsByTagName('assert')->item($i);
        // access the parent "MPD" in mpd file
        $schematronIssue[$i]->text = getSchemaErrorText($errorElement);
        $schematronIssue[$i]->location = getSchemaErrorLocation($errorElement);
        // get mediapersentation duration from mpd level
        $schematronIssue[$i]->attributes = getSchemaErrorAttributes($errorElement);
        // get mediapersentation duration from mpd level
        //$SchematronErrorLocations[] = getSchemaErrorLocation($errorElement->getAttribute('location')); // get mediapersentation duration from mpd level
    }
    return $schematronIssue;
}
开发者ID:vinum,项目名称:Conformance-Software,代码行数:28,代码来源:schematronIssuesAnalyzer.php

示例12: testGrandchild

 public function testGrandchild()
 {
     $root = new SXE('<root><child1 /><child2 /><child3><grandchild /></child3></root>');
     $grandchild = $root->child3->lastChild();
     $this->assertTrue($grandchild instanceof SXE);
     $this->assertSame(dom_import_simplexml($root->child3->grandchild), dom_import_simplexml($grandchild));
 }
开发者ID:laiello,项目名称:sxe,代码行数:7,代码来源:lastChild.php

示例13: getQuestion

	/** hack to Just Get A Question from current dmid, using Excercise class
	 * to do our factorying for us. 
	 * Obviously the factory code needs to be refactored to ElseWhere, but not on Sunday 
	 * :-P
	 * (Sun 15 Jun 2008)
	 */
	function getQuestion( $dmid, $questionLanguages, $answerLanguages ) {
		if ( !$questionLanguages )
			throw new Exception( "Vocview: no question (original) languages provided!" );

		if ( !$answerLanguages )
			throw new Exception( "Vocview: no answer (translation) languages provided!" );
		/* 3 men walked into a bar^wExercise
		 * fullset, fetcher, and subset
		 */

		/* our regular fetcher is provided by functions.php 
		 * I suppose if I were tidier, I could use fetchers for
		 * persistence
		 */
		$fetcher = new OWFetcher();

		/* fullset is a domdocument containing a <collection> of
		 * empty <defined-meanings/> (just their defined-meaning-id
		 * attribute is set)
		 * This format makes sense on some days, it's just
		 * massive nukular overkill today, specially since
		 * we only have 1 element :-P
		 * Still, if Exercise wants this as a dom, we can oblige.
		 */
		$xmlString = "
			<collection>
				<defined-meaning defined-meaning-id=\"$dmid\" />
			</collection>
		";
		$xml = simplexml_load_string( $xmlString );
		$fullset = dom_import_simplexml( $xml )->ownerDocument;
		# et voila. 

		/* subset is a selection of stuff we are actually
		 * interested in, from the above, as an array of 
		 * dmid's .... Oh look! We have just one!
		 */
		$subset = array( $dmid ); # :-P
		# (ok, to be honest, it does also get auto-generated
		# from the fullset, if we say nothing... but
		# then where would the joke be? )

		# and we already had the fetcher.
		# So the fullset said to the fetcher: let's do this! 

		$exercise = new Exercise( $fetcher, $fullset, $subset );
		$exercise->setQuestionLanguages( $questionLanguages );
		$exercise->setAnswerLanguages( $answerLanguages );
		
		# Ok, now let's see. which question did we need?
		# (and setting selfcheck to false)
		$question = $exercise->getQuestion( $dmid, false );
		# Oh REALLY! And we needed to go through all that?

		# well, let's return it, before people start asking
		# more difficult questions.

		return $question;
		
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:66,代码来源:vocview.php

示例14: simpleXmlElementToDomDocument

 /**
  * Create a dom document based on a SimpleXMLElement
  *
  * @param SimpleXMLElement $xml_element
  *
  * @return \DOMDocument
  */
 private function simpleXmlElementToDomDocument(SimpleXMLElement $xml_element)
 {
     $dom = new DOMDocument("1.0", "UTF-8");
     $dom_element = $dom->importNode(dom_import_simplexml($xml_element), true);
     $dom->appendChild($dom_element);
     return $dom;
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:14,代码来源:RNGValidator.class.php

示例15: addCData

 public function addCData($nodename, $cdata_text)
 {
     $node = $this->addChild($nodename);
     $node = dom_import_simplexml($node);
     $no = $node->ownerDocument;
     $node->appendChild($no->createCDATASection($cdata_text));
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:7,代码来源:treepodia.php


注:本文中的dom_import_simplexml函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。