QuickBooks/XML/Node.php
public function _asXMLHelper($node, $tabs, $empty, $indent)
	{
		$xml = '';

		if ($node->childCount())
		{
			$xml .= str_repeat($indent, $tabs) . '<' . $node->name();

			foreach ($node->attributes() as $key => $value)
			{
				// Make sure double-encode is *off*
				//$xml .= ' ' . $key . '="' . QuickBooks_XML::encode($value, true, false) . '"';
				$xml .= ' ' . $key . '="' . QuickBooks_XML::encode($value) . '"';
			}

			$xml .= '>' . "\n";
			foreach ($node->children() as $child)
			{
				$xml .= $this->_asXMLHelper($child, $tabs + 1, $empty, $indent);
			}
			$xml .= str_repeat($indent, $tabs) . '</' . $node->name() . '>' . "\n";
		}
		else
		{
			if ($node->hasAttributes())		// if the node has attributes, we'll build the whole thing no matter what
			{
				$xml .= str_repeat($indent, $tabs) . '<' . $node->name();

				foreach ($node->attributes() as $key => $value)
				{
					// Double-encode is *off*
					//$xml .= ' ' . $key . '="' . QuickBooks_XML::encode($value, true, false) . '"';
					$xml .= ' ' . $key . '="' . QuickBooks_XML::encode($value) . '"';
				}

				// Double-encode is *off*
				//$xml .= '>' . QuickBooks_XML::encode($node->data(), true, false) . '</' . $node->name() . '>' . "\n";
				$xml .= '>' . QuickBooks_XML::encode($node->data()) . '</' . $node->name() . '>' . "\n";
			}
			else
			{
				if ($node->data() == '__EMPTY__')		// ick, bad hack
				{
					$xml .= str_repeat($indent, $tabs) . '<' . $node->name() . '></' . $node->name() . '>' . "\n";
				}
				else if ($node->hasData() or $empty == QuickBooks_XML::XML_PRESERVE)
				{
					// Double-encode is *off*
					//$xml .= str_repeat($indent, $tabs) . '<' . $node->name() . '>' . QuickBooks_XML::encode($node->data(), true, false) . '</' . $node->name() . '>' . "\n";
					$xml .= str_repeat($indent, $tabs) . '<' . $node->name() . '>' . QuickBooks_XML::encode($node->data()) . '</' . $node->name() . '>' . "\n";
				}
				else if ($empty == QuickBooks_XML::XML_COMPRESS)
				{
					$xml .= str_repeat($indent, $tabs) . '<' . $node->name() . ' />' . "\n";
				}
				else if ($empty == QuickBooks_XML::XML_DROP)
				{
					; // do nothing, drop the empty element
				}
			}


		}

		return $xml;
	}
public function _asXMLHelper($node, $tabs, $empty, $indent)
	{
		$xml = '';

		if ($node->childCount())
		{
			$xml .= str_repeat($indent, $tabs) . '<' . $node->name();

			foreach ($node->attributes() as $key => $value)
			{
				// Make sure double-encode is *off*
				//$xml .= ' ' . $key . '="' . QuickBooks_XML::encode($value, true, false) . '"';
				$xml .= ' ' . $key . '="' . QuickBooks_XML::encode($value) . '"';
			}

			$xml .= '>' . "\n";
			foreach ($node->children() as $child)
			{
				$xml .= $this->_asXMLHelper($child, $tabs + 1, $empty, $indent);
			}
			$xml .= str_repeat($indent, $tabs) . '</' . $node->name() . '>' . "\n";
		}
		else
		{
			if ($node->hasAttributes())		// if the node has attributes, we'll build the whole thing no matter what
			{
				$xml .= str_repeat($indent, $tabs) . '<' . $node->name();

				foreach ($node->attributes() as $key => $value)
				{
					// Double-encode is *off*
					//$xml .= ' ' . $key . '="' . QuickBooks_XML::encode($value, true, false) . '"';
					$xml .= ' ' . $key . '="' . QuickBooks_XML::encode($value) . '"';
				}

				// Double-encode is *off*
				//$xml .= '>' . QuickBooks_XML::encode($node->data(), true, false) . '</' . $node->name() . '>' . "\n";
				$xml .= '>' . QuickBooks_XML::encode($node->data()) . '</' . $node->name() . '>' . "\n";
			}
			else
			{
				if ($node->data() == '__EMPTY__')		// ick, bad hack
				{
					$xml .= str_repeat($indent, $tabs) . '<' . $node->name() . '></' . $node->name() . '>' . "\n";
				}
				else if ($node->hasData() or $empty == QuickBooks_XML::XML_PRESERVE)
				{
					// Double-encode is *off*
					//$xml .= str_repeat($indent, $tabs) . '<' . $node->name() . '>' . QuickBooks_XML::encode($node->data(), true, false) . '</' . $node->name() . '>' . "\n";
					$xml .= str_repeat($indent, $tabs) . '<' . $node->name() . '>' . QuickBooks_XML::encode($node->data()) . '</' . $node->name() . '>' . "\n";
				}
				else if ($empty == QuickBooks_XML::XML_COMPRESS)
				{
					$xml .= str_repeat($indent, $tabs) . '<' . $node->name() . ' />' . "\n";
				}
				else if ($empty == QuickBooks_XML::XML_DROP)
				{
					; // do nothing, drop the empty element
				}
			}


		}

		return $xml;
	}
Resursive helper function for converting to XML

@param QuickBooks_XML_Node $node
@param integer $tabs
@param boolean $empty				A constant, one of: QUICKBOOKS_XML_XML_PRESERVE, QUICKBOOKS_XML_XML_DROP, QUICKBOOKS_XML_XML_COMPRESS
@param string $indent
@return string