本文整理汇总了PHP中Xml::createElement方法的典型用法代码示例。如果您正苦于以下问题:PHP Xml::createElement方法的具体用法?PHP Xml::createElement怎么用?PHP Xml::createElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xml
的用法示例。
在下文中一共展示了Xml::createElement方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOwnerAssignment
/**
* testOwnerAssignment method
*
* @access public
* @return void
*/
function testOwnerAssignment()
{
$xml = new Xml();
$node =& $xml->createElement('hello', 'world');
$owner =& $node->document();
$this->assertTrue($xml === $owner);
$children =& $node->children;
$childOwner =& $children[0]->document();
$this->assertTrue($xml === $childOwner);
}
示例2: importXml
static function importXml($elem, $model)
{
$n = null;
if ($elem->nodeType == Xml::$Element) {
$n = Xml::createElement($elem->getNodeName());
$keys = $elem->attributes();
while ($keys->hasNext()) {
$key = $keys->next();
$n->set($key, $elem->get($key));
unset($key);
}
$children = $elem->iterator();
while ($children->hasNext()) {
$n->addChild(com_wiris_util_xml_WXmlUtils::importXml($children->next(), $model));
}
} else {
if ($elem->nodeType == Xml::$Document) {
$n = com_wiris_util_xml_WXmlUtils::importXml($elem->firstElement(), $model);
} else {
if ($elem->nodeType == Xml::$CData) {
$n = Xml::createCData($elem->getNodeValue());
} else {
if ($elem->nodeType == Xml::$PCData) {
$n = Xml::createPCData($elem->getNodeValue());
} else {
throw new HException("Unsupported node type: " . Std::string($elem->nodeType));
}
}
}
}
return $n;
}
示例3: _makeContent
private function _makeContent($fileName)
{
$this->out(sprintf(__('Creating package request for: %s', true), basename($fileName)));
$name = $this->_removeExtension($fileName);
$doc = new Xml(null, array(), $this->adeptNs);
$packageElement = $doc->createElement('package', null, null);
$packageElement->addNamespace("", $this->adeptNs);
$xmlSourceDoc = $this->_useXmlSource($fileName);
if ($this->useXmlSource && $xmlSourceDoc == null) {
$this->out(__('An Error occured with the XML Source', true));
$this->errors++;
$this->failedFiles .= basename($fileName) . "\n";
return null;
}
if ($this->hasResource) {
$packageElement->createElement('resource', $xmlSourceDoc->children[0]->child('resource')->children[0]->value, null);
}
if ($this->hasVoucher) {
$packageElement->createElement('voucher', $xmlSourceDoc->children[0]->child('voucher')->children[0]->value, null);
}
if ($this->hasResourceItem) {
$packageElement->createElement('resourceItem', $xmlSourceDoc->children[0]->child('resourceItem')->children[0]->value, null);
}
if ($this->hasLocation) {
$packageElement->createElement('location', $xmlSourceDoc->children[0]->child('locaton')->children[0]->value, null);
}
if ($this->hasSrc) {
$packageElement->createElement('src', $xmlSourceDoc->children[0]->child('src')->children[0]->value, null);
}
if ($this->hasMetadata || $this->hasDefaultMetadata) {
$metadataElement = $packageElement->createElement('metadata', null, null);
$metadataElement->addNamespace($this->dublinCorePrefix, $this->dublinCoreNs);
if (!$this->title == "") {
$metadataElement->createElement('dc:title', $this->title, null);
} elseif ($this->title == "" && !$this->titleDefault == "") {
$metadataaElement->createElement('dc:title', $this->titleDefault, null);
}
if (!$this->description == "") {
$metadataElement->createElement('dc:description', $this->description, null);
} elseif ($this->description == "" && !$this->descriptionDefault == "") {
$metadataaElement->createElement('dc:description', $this->descriptionDefault, null);
}
if (!$this->language == "") {
$metadataElement->createElement('dc:language', $this->language, null);
} elseif ($this->language == "" && !$this->languageDefault == "") {
$metadataaElement->createElement('dc:language', $this->languageDefault, null);
}
if (!$this->creator == "") {
$metadataElement->createElement('dc:creator', $this->creator, null);
} elseif ($this->creator == "" && !$this->creatorDefault == "") {
$metadataaElement->createElement('dc:creator', $this->creatorDefault, null);
}
if (!$this->publisher == "") {
$metadataElement->createElement('dc:publisher', $this->publisher, null);
} elseif ($this->publisher == "" && !$this->publisherDefault == "") {
$metadataaElement->createElement('dc:publisher', $this->publisherDefault, null);
}
if (!$this->format == "") {
$metadataElement->createElement('dc:format', $this->format, null);
} elseif ($this->format == "" && !$this->formatDefault == "") {
$metadataaElement->createElement('dc:format', $this->formatDefault, null);
}
}
if ($this->hasPermissions) {
$packageElement->append($xmlSourceDoc->children[0]->child('permissions'));
}
if ($this->hasDataPath && $this->useDataPath) {
$packageElement->createElement('dataPath', $xmlSourceDoc->children[0]->child('dataPath')->children[0]->value);
} else {
$file = '';
if ($this->hasFileName) {
if (is_file($xmlSourceDoc->children[0]->child('fileName')->children[0]->value)) {
$file = new File($xmlSourceDoc->children[0]->child('fileName')->children[0]->value);
} elseif (is_file(dirname($fileName) . "/" . basename($xmlSourceDoc->children[0]->child('fileName')->children[0]->value))) {
$file = new File(dirname($fileName) . "/" . basename($xmlSourceDoc->children[0]->child('fileName')->children[0]->value));
}
}
if (is_object($file)) {
$packageElement->createElement('fileName', $file->name, null);
$packageElement->createElement('data', base64_encode($file->read()));
}
}
if ($this->hasThumbnailLocation) {
$packageElement->createElement('thumbnailLocation', $xmlSourceDoc->children[0]->child('thumbnailLocation')->children[0]->value);
}
if ($this->thumbPNG || $this->thumbJPEG || $this->thumbJPG || $this->thumbGIF) {
$thumbnailName = $this->_getThumbnail($fileName);
if ($thumbnailName != null) {
$file = new File(dirname($fileName) . "/" . $thumbnailName);
if ($file) {
if ($this->verbose) {
$this->out(sprintf(__('Found thumbnail file', true), $thumbnailName));
}
$packageElement->createElement('thumbnailData', base64_encode($file->read()));
}
} else {
$this->out(__('Cannot find thumbnail file', true));
}
} elseif ($xmlSourceDoc->children[0]->child('thumbnailName') != null) {
$file = '';
//.........这里部分代码省略.........
示例4: __start_element_handler
static function __start_element_handler($parser, $name, $attribs)
{
$node = Xml::createElement($name);
while (list($k, $v) = each($attribs)) {
$node->set($k, $v);
}
Xml::$build->addChild($node);
Xml::$build = $node;
}
示例5: buildXML
/**
* Builds the complete xml document.
* @return string
* @access private
*/
protected function buildXML()
{
$hp = new Xml('1.0', 'utf-8');
$hp->formatOutput = true;
// begin hp items
$hpitems = $hp->createElement('hotPadsItems');
$hpitems->setAttribute("version", '2.1');
$comm = $hp->createComment('Generated at ' . gmdate(DATE_RFC822));
$hpitems->appendChild($comm);
if (is_array($this->properties)) {
foreach ($this->properties as $prop) {
$noerrors = $this->validate($prop);
if ($noerrors === true) {
// Build listing
$listing = $hp->createElement('Listing');
// Listing attributes
$listing->setAttribute("id", $prop->id);
$listing->setAttribute("type", $prop->type);
$listing->setAttribute("propertyType", $prop->property_type);
// Property details
$listing->appendChild($this->hpTextNode('name', false, $hp, $prop));
$listing->appendChild($this->hpTextNode('unit', false, $hp, $prop));
$listing->appendChild($this->hpTextNode('street', false, $hp, $prop));
$listing->appendChild($this->hpTextNode('city', false, $hp, $prop));
$listing->appendChild($this->hpTextNode('state', false, $hp, $prop));
$listing->appendChild($this->hpTextNode('zip', false, $hp, $prop));
$listing->appendChild($this->hpTextNode('country', false, $hp, $prop));
// Contact details
$listing->appendChild($this->hpTextNode('contactName', 'contact_name', $hp, $prop));
$listing->appendChild($this->hpTextNode('contactEmail', 'contact_email', $hp, $prop));
$listing->appendChild($this->hpTextNode('contactPhone', 'contact_phone', $hp, $prop));
$listing->appendChild($this->hpTextNode('contactFax', 'contact_fax', $hp, $prop));
// Descriptions and urls
$listing->appendChild($this->hpTextNode('previewMessage', 'preview_message', $hp, $prop));
$listing->appendChild($this->hpTextNode('description', false, $hp, $prop));
$listing->appendChild($this->hpTextNode('terms', false, $hp, $prop));
$listing->appendChild($this->hpTextNode('website', 'website_url', $hp, $prop));
$listing->appendChild($this->hpTextNode('virtualTourUrl', 'vr_url', $hp, $prop));
// Photos
if ($prop->photos) {
foreach ($prop->photos as $img) {
$photo = $hp->createElement('ListingPhoto');
$photo->setAttribute("source", $img['source']);
$listing->appendChild($photo);
}
}
// Additional data
$listing->appendChild($this->hpTextNode('price', false, $hp, $prop));
$listing->appendChild($this->hpTextNode('pricingFrequency', 'price_freq', $hp, $prop));
$listing->appendChild($this->hpTextNode('HOA-Fee', 'hoa_maint', $hp, $prop));
$listing->appendChild($this->hpTextNode('numBedrooms', 'bedrooms', $hp, $prop));
$listing->appendChild($this->hpTextNode('numFullBaths', 'full_bath', $hp, $prop));
$listing->appendChild($this->hpTextNode('numHalfBaths', 'half_bath', $hp, $prop));
$listing->appendChild($this->hpTextNode('squareFeet', 'sqft', $hp, $prop));
$hpitems->appendChild($listing);
}
}
$hp->appendChild($hpitems);
return $hp->saveXML();
}
}