本文整理汇总了PHP中XMLWriter::StartElement方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::StartElement方法的具体用法?PHP XMLWriter::StartElement怎么用?PHP XMLWriter::StartElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::StartElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postflight
/**
* method to run after an install/update/uninstall method
*
* @param $type
* @param $parent
*
* @return void
*/
public function postflight($type, $parent)
{
$db =& JFactory::getDBO();
$handle = fopen("components/com_vproductfeed/assets/data/GoogleCategories.txt", "r");
$previous = array();
$root = array("id" => 0, "name" => "");
$child = array("id" => 0, "name" => "");
$count = 0;
$parent_id = 0;
while (($line = fgets($handle)) !== false) {
$nodes = explode(">", $line);
if (count($nodes) > 1) {
//process the nodes
foreach ($nodes as $value) {
$count++;
$child[0] = $count;
$child[1] = htmlspecialchars(trim($value), ENT_QUOTES);
//insert into database and xref
$q = "Insert Into google_category (category_id, category_name) \r\n\t\t\t\t\t values (" . $child[0] . ", '" . $child[1] . "')";
$db->setQuery($q);
$result = $db->query();
//$result = mysql_query($q);
if ($result == true) {
//This checks if the category_name already exists
$q = "Insert Into google_category_xref (category_parent_id, category_child_id) \r\n\t\t\t\t\t\tvalues (" . $parent_id . ", " . $child[0] . ")";
$db->setQuery($q);
$result = $db->query();
//$result = mysql_query($q);
} else {
//get the Id of the category already in db
$q = "select `category_id` from `google_category` where `category_name`='" . $child[1] . "'";
//echo "Query: " . $q . "<br />";
$db->setQuery($q);
$result = $db->query();
//$result = mysql_query($q);
if (!$result) {
echo "Problem Executing Query";
exit;
}
$row = $db->loadRow();
//$row = mysql_fetch_row($result);
$parent_id = $row[0];
$count--;
}
}
$parent_id = $root[0];
} else {
//process the root node
$count++;
$root[0] = $count;
$root[1] = htmlspecialchars(trim($nodes[0]), ENT_QUOTES);
$parent_id = $root[0];
echo "Writing root: " . $root[1] . "<br />";
//insert into database and xref
$q = "Insert Into google_category (category_id, category_name) values (" . $root[0] . ", '" . $root[1] . "')";
//mysql_query($q);
$db->setQuery($q);
$result = $db->query();
$q = "Insert Into google_category_xref (category_parent_id, category_child_id) values (0, " . $root[0] . ")";
//mysql_query($q);
$db->setQuery($q);
$result = $db->query();
}
foreach ($nodes as $value) {
$previous[] = $value;
}
}
//now put vm categories in an xml file
$params = JComponentHelper::getParams('com_languages');
$lang = $params->get('site', 'en-GB');
//use default joomla
$lang = strtolower(strtr($lang, '-', '_'));
$q = "SELECT c.virtuemart_category_id, c.category_name FROM `#__virtuemart_categories_{$lang}` as c\r\n\t\t\t JOIN `#__virtuemart_category_categories` as x\r\n\t\t\t ON x.category_child_id = c.virtuemart_category_id\r\n\t\t\t WHERE x.category_parent_id = 0\r\n\t\t\t ORDER BY c.category_name";
$db->setQuery($q);
//$result = $db->query();
//$result = mysql_query($q);
$error = $db->getErrorMsg();
if (!empty($error)) {
$app = JFactory::getApplication();
$app->enqueueMessage('Error Getting Data: ' . $error);
}
$writer = new XMLWriter();
$writer->openURI('components/com_vproductfeed/assets/data/file.xml');
$writer->startDocument('1.0');
$writer->setIndent(4);
$writer->startElement('tree');
$writer->writeAttribute('id', '0');
$row = $db->loadRowList();
for ($i = 0; $i < sizeof($row); $i++) {
echo "Root Row: " . $row[$i][0] . " - " . $row[$i][1] . "<br />";
$writer->StartElement('item');
$writer->writeAttribute('id', $row[$i][0]);
//.........这里部分代码省略.........
示例2: XMLWriter
//$result = mysql_query($q);
$error = $db->getErrorMsg();
if (!empty($error)) {
$app = JFactory::getApplication();
$app->enqueueMessage('Error Getting Data: ' . $error);
}
$writer = new XMLWriter();
$writer->openURI('components/com_vproductfeed/assets/data/file.xml');
$writer->startDocument('1.0');
$writer->setIndent(4);
$writer->startElement('tree');
$writer->writeAttribute('id', '0');
$row = $db->loadRowList();
for ($i = 0; $i < sizeof($row); $i++) {
//echo "Root Row: " . $row[$i][0] . " - " . $row[$i][1] . "<br />";
$writer->StartElement('item');
$writer->writeAttribute('id', $row[$i][0]);
$writer->writeAttribute('text', $row[$i][1]);
$writer->writeAttribute('select', '1');
$db1 =& JFactory::getDBO();
$q1 = "SELECT c.virtuemart_category_id, c.category_name FROM `#__virtuemart_categories_{$lang}` as c\r\n\t\t \t\t\t JOIN `#__virtuemart_category_categories` as x\r\n\t\t\t\t\t ON x.category_child_id = c.virtuemart_category_id\r\n\t\t\t\t\t WHERE x.category_parent_id = " . $row[$i][0] . " order by c.category_name";
$db1->setQuery($q1);
$row1 = $db1->loadRowList();
for ($i1 = 0; $i1 < sizeof($row1); $i1++) {
//echo " Level 1 Row: " . $row1[$i1][0] . " - " . $row1[$i1][1] . "<br />";
$writer->StartElement('item');
$writer->writeAttribute('id', $row1[$i1][0]);
$writer->writeAttribute('text', $row1[$i1][1]);
$writer->writeAttribute('select', '1');
$db2 =& JFactory::getDBO();
$q2 = "SELECT c.virtuemart_category_id, c.category_name FROM `#__virtuemart_categories_{$lang}` as c\r\n\t\t \t\t\t JOIN `#__virtuemart_category_categories` as x\r\n\t\t\t\t\t ON x.category_child_id = c.virtuemart_category_id\r\n\t\t\t\t\t WHERE x.category_parent_id = " . $row1[$i1][0] . " order by c.category_name";
示例3: generateMPD
public function generateMPD($duration, $nStart, $nSegs)
{
$id = $this->__file->getId();
$savePath = $this->__file->getSavedir() . "{$id}.mpd";
$xml = new XMLWriter();
if (file_exists($savePath)) {
unlink($savePath);
}
$xml->openURI($savePath);
$xml->setIndent(TRUE);
$xml->startDocument('1.0', 'UTF-8');
$xml->startElement('MPD');
$xml->writeAttribute('xmlns', 'urn:mpeg:dash:schema:mpd:2011');
$xml->writeAttribute('minBufferTime', 'PT1.500000S');
$xml->writeAttribute('type', 'static');
$xml->writeAttribute('mediaPresentationDuration', 'PT0H9M56.50S');
$xml->writeAttribute('profiles', 'urn:mpeg:dash:profile:isoff-main:2011');
$xml->writeElement('BaseURL', 'http://pilatus.d1.comp.nus.edu.sg/');
//$xml->writeElement('BaseURL', 'http://pluto.comp.nus.edu.sg/');
$xml->StartElement('Period');
$xml->writeAttribute('duration', "PT{$duration[0]}H{$duration[1]}M{$duration[2]}S");
$xml->writeElement('BaseURL', "~team08/video_repo/{$id}/");
//$xml->writeElement('BaseURL', "dash/video_repo/$id/" );
$xml->StartElement('AdaptationSet');
$xml->writeAttribute('segmentAlignment', 'true');
$xml->writeAttribute('maxWidth', '720');
$xml->writeAttribute('maxHeight', '480');
$xml->writeAttribute('maxFrameRate', '30');
$xml->writeAttribute('par', '3:2');
$xml->StartElement('ContentComponent');
$xml->writeAttribute('id', '1');
$xml->writeAttribute('contentType', 'video');
$xml->EndElement();
$xml->StartElement('ContentComponent');
$xml->writeAttribute('id', '2');
$xml->writeAttribute('contentType', 'audio');
$xml->EndElement();
$xml->StartElement('Representation');
$xml->writeAttribute('id', 'HIGH');
$xml->writeAttribute('mimeType', 'video/mp4');
$xml->writeAttribute('codecs', 'avc1,mp4a');
$xml->writeAttribute('width', '720');
$xml->writeAttribute('height', '480');
$xml->writeAttribute('frameRate', '30');
$xml->writeAttribute('sar', '1:1');
$xml->writeAttribute('audioSamplingRate', '48000');
$xml->writeAttribute('bandwidth', '3000000');
$xml->StartElement('SegmentList');
$xml->writeAttribute('duration', '3');
for ($i = $nStart; $i <= $nSegs; $i++) {
$xml->StartElement('SegmentURL');
$xml->writeAttribute('media', "{$i}_720x480.mp4");
$xml->EndElement();
}
$xml->EndElement();
$xml->EndElement();
$xml->StartElement('Representation');
$xml->writeAttribute('id', 'MEDIUM');
$xml->writeAttribute('mimeType', 'video/mp4');
$xml->writeAttribute('codecs', 'avc1,mp4a');
$xml->writeAttribute('width', '480');
$xml->writeAttribute('height', '320');
$xml->writeAttribute('frameRate', '30');
$xml->writeAttribute('sar', '1:1');
$xml->writeAttribute('audioSamplingRate', '48000');
$xml->writeAttribute('bandwidth', '768000');
$xml->StartElement('SegmentList');
$xml->writeAttribute('duration', '3');
for ($i = $nStart; $i <= $nSegs; $i++) {
$xml->StartElement('SegmentURL');
$xml->writeAttribute('media', "{$i}_480x320.mp4");
$xml->EndElement();
}
$xml->EndElement();
$xml->EndElement();
$xml->StartElement('Representation');
$xml->writeAttribute('id', 'LOW');
$xml->writeAttribute('mimeType', 'video/mp4');
$xml->writeAttribute('codecs', 'avc1,mp4a');
$xml->writeAttribute('width', '240');
$xml->writeAttribute('height', '160');
$xml->writeAttribute('frameRate', '30');
$xml->writeAttribute('sar', '1:1');
$xml->writeAttribute('audioSamplingRate', '48000');
$xml->writeAttribute('bandwidth', '200000');
$xml->StartElement('SegmentList');
$xml->writeAttribute('duration', '3');
for ($i = $nStart; $i <= $nSegs; $i++) {
$xml->StartElement('SegmentURL');
$xml->writeAttribute('media', "{$i}_240x160.mp4");
$xml->EndElement();
}
$xml->EndElement();
$xml->EndElement();
$xml->EndElement();
$xml->EndElement();
$xml->EndElement();
$xml->endDocument();
$xml->flush();
}