Jeremy
in memoriam 1991-2020
OK, I'm working on the next version of BBCM and I am currently fighting with an XML output. Here's my issue:
The code that I wrote, based off of XenForo's export add-on code and checked against XenPorta, doesn't create a proper XML output. Every time I go to the page to view it... I get a "The requested page is unrepresentable as XML." error. Here's my code:
I have no idea why to do here... Thoughts?
Edit: I modified the replacementEnd / replacementBegin to be CDATA sections because they contain HTML, but it still fails. Here's what my current code is:
The code that I wrote, based off of XenForo's export add-on code and checked against XenPorta, doesn't create a proper XML output. Every time I go to the page to view it... I get a "The requested page is unrepresentable as XML." error. Here's my code:
PHP:
public function getBbCodeXml(array $bbcode)
{
$document = new DOMDocument('1.0', 'utf-8');
$document->formatOutput = true;
$rootNode = $document->createElement('bbcode');
$document->appendChild($rootNode);
$rootNode->appendChild($document->createElement('tag', $bbcode['tag']));
$rootNode->appendChild($document->createElement('title', $bbcode['title']));
$rootNode->appendChild($document->createElement('description', $bbcode['description']));
$replacement = $rootNode->appendChild($document->createElement('replacement'));
$replacement->appendChild($document->createElement('begin', $bbcode['replacementBegin']));
$replacement->appendChild($document->createElement('end', $bbcode['replacementEnd']));
$phpcallback = $rootNode->appendChild($document->createElement('phpcallback'));
$phpcallback->appendChild($document->createElement('class', $bbcode['phpcallback_class']));
$phpcallback->appendChild($document->createElement('method', $bbcode['phpcallback_method']));
$rootNode->appendChild($document->createElement('example', $bbcode['example']));
$rootNode->appendChild($document->createElement('active', $bbcode['active']));
$rootNode->appendChild($document->createElement('requiresOption', $bbcode['requiresOption']));
$rootNode->appendChild($document->createElement('advancedOptions', $bbcode['advancedOptions']));
$rootNode->appendChild($document->createElement('numberOfOptions', $bbcode['numberOfOptions']));
$rootNode->appendChild($document->createElement('regex', $bbcode['regex']));
$rootNode->appendChild($document->createElement('trimLeadingLinesAfter', $bbcode['trimLeadingLinesAfter']));
$rootNode->appendChild($document->createElement('plainCallback', $bbcode['plainCallback']));
$rootNode->appendChild($document->createElement('plainChildren', $bbcode['plainChildren']));
$rootNode->appendChild($document->createElement('stopSmilies', $bbcode['stopSmilies']));
$rootNode->appendChild($document->createElement('stopLineBreakConversion', $bbcode['stopLineBreakConversion']));
XenForo_Application::autoload('Zend_Debug');
Zend_Debug::dump($document);
return $document;
}
I have no idea why to do here... Thoughts?
Edit: I modified the replacementEnd / replacementBegin to be CDATA sections because they contain HTML, but it still fails. Here's what my current code is:
PHP:
public function getBbCodeXml(array $bbcode)
{
$document = new DOMDocument('1.0', 'utf-8');
$document->formatOutput = true;
$rootNode = $document->createElement('bbcode');
$document->appendChild($rootNode);
$rootNode->appendChild($document->createElement('tag', $bbcode['tag']));
$rootNode->appendChild($document->createElement('title', $bbcode['title']));
$rootNode->appendChild($document->createElement('description', $bbcode['description']));
$replacement = $rootNode->appendChild($document->createElement('replacement'));
$replacementBegin = $replacement->appendChild($document->createElement('begin', ''));
$replacementBegin->appendChild($document->createCDATASection($bbcode['replacementBegin']));
$replacementEnd = $replacement->appendChild($document->createElement('end', ''));
$replacementEnd->appendChild($document->createCDATASection($bbcode['replacementEnd']));
$phpcallback = $rootNode->appendChild($document->createElement('phpcallback'));
$phpcallback->appendChild($document->createElement('class', $bbcode['phpcallback_class']));
$phpcallback->appendChild($document->createElement('method', $bbcode['phpcallback_method']));
$rootNode->appendChild($document->createElement('example', $bbcode['example']));
$rootNode->appendChild($document->createElement('active', $bbcode['active']));
$rootNode->appendChild($document->createElement('requiresOption', $bbcode['requiresOption']));
$rootNode->appendChild($document->createElement('advancedOptions', $bbcode['advancedOptions']));
$rootNode->appendChild($document->createElement('numberOfOptions', $bbcode['numberOfOptions']));
$rootNode->appendChild($document->createElement('regex', $bbcode['regex']));
$rootNode->appendChild($document->createElement('trimLeadingLinesAfter', $bbcode['trimLeadingLinesAfter']));
$rootNode->appendChild($document->createElement('plainCallback', $bbcode['plainCallback']));
$rootNode->appendChild($document->createElement('plainChildren', $bbcode['plainChildren']));
$rootNode->appendChild($document->createElement('stopSmilies', $bbcode['stopSmilies']));
$rootNode->appendChild($document->createElement('stopLineBreakConversion', $bbcode['stopLineBreakConversion']));
// XenForo_Application::autoload('Zend_Debug');
// Zend_Debug::dump($document);
return $document;
}