static public function encode($str, $for_qbxml = true, $double_encode = true)
	{
		$transform = array(
			'&' => '&amp;', 
			'<' => '&lt;', 
			'>' => '&gt;', 
			//'\'' => '&apos;', 
			'"' => '&quot;', 
			);
		
		$str = str_replace(array_keys($transform), array_values($transform), $str);
		
		if (!$double_encode)
		{
			$fix = array();
			foreach ($transform as $raw => $encoded)
			{
				$fix[str_replace('&', '&amp;', $encoded)] = $encoded;
			}
			
			$str = str_replace(array_keys($fix), array_values($fix), $str);
		}
		
		return $str;
	}