Пример #1
0
VMINT vm_xml_parse(
	VM_XML_PARSER_STRUCT *parser,
	const VMCHAR *xmlsource,
	VMINT length)
{
	int ret = VM_XML_RESULT_FAIL;

	ret = xml_new_parser(&mtk_xml_parser);

	if (XML_RESULT_OK != ret)
	{
		MMI_TRACE(MMI_MRE_TRC_ERROR, TRC_MRE_VMXML_336 , ret);
		xml_close_parser(&mtk_xml_parser);
		return -1;
	}
	
	xml_configure_memory(&mtk_xml_parser, vm_malloc, vm_free);

		
    xml_register_doctype_handler(
	   	&mtk_xml_parser, 
	   	parser->start_doctype_hdlr, 
	   	parser->end_doctype_hdlr);
	   
    xml_register_element_handler(
	   	&mtk_xml_parser, 
	   	parser->start_elem_hdlr, 
	   	parser->end_elem_hdlr);
	   
    xml_register_data_handler(
	   	&mtk_xml_parser, 
	   	parser->data_hdlr);
	   
	if(0 == length)
	{
		ret = xml_parse(&mtk_xml_parser, (VMUWSTR)vm_ucs2_string_by_ascii((VMSTR)xmlsource));
	}
	else
	{
		ret = xml_parse_buffer(&mtk_xml_parser, xmlsource, length);
	}

	xml_close_parser(&mtk_xml_parser);

	if (XML_RESULT_OK!= ret)
	{
 		return -1;
	}

	return VM_XML_RESULT_OK;
}
Пример #2
0
/*****************************************************************************
 * FUNCTION
 *  mmi_dcd_get_attr_from_sl
 * DESCRIPTION
 *  this function is used to get tagname by token 
 * PARAMETERS
 *  filename        [IN]        File name of wap push sl
 *  url             [IN]        [out]       buf to save url
 *  action          [IN]        [out]       buf to save action
 * RETURNS
 *  if < 0: failed
 *****************************************************************************/
int mmi_dcd_get_attr_from_sl(const kal_wchar  * filename, 
						   kal_char ** url,  kal_char ** action)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
	XML_PARSER_STRUCT parser;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    g_sl_url_p = NULL;
    g_sl_action_p = NULL;

	xml_new_parser (&parser);

    /* xml_configure_memory (&parser, get_ctrl_buffer, free_ctrl_buffer); */

    xml_register_element_handler(&parser, dcd_xml_start_elem_hdlr, dcd_xml_end_elem_hdlr);

	xml_register_data_handler(&parser, dcd_xml_data_hdlr);

	xml_parse(&parser, (kal_wchar*)filename);

	xml_close_parser(&parser);

    if (url)
    {
	    *url = g_sl_url_p;
    }
    if (action)
    {
	    *action = g_sl_action_p;
    }
    /* no need to free, caller will free it */

	return 1;
}