ScicosLab Function
Last update : 18/05/2014

XML_Parse - Parse XML strings

Calling Sequence

XML_Parse(%ptr,txt)

Parameters

Description

This function run the XML parser. The XML pointer must be created with XML_ParserCreate.

Note that :

  • When an error is encountered during the parsing, the XML pointer is automatically free.
  • When the parsing is successful, the XML pointer is automatically free.
  • Examples

       txt = mgetl('SCI/man/eng/expatsci/XML_Parse.xml');
       data = struct('store',%f,'tag','PARAM_NAME','str',[]);
       
       function [data]=char_handl(data,txt)
         if data.store then
           data.str=[data.str;
                     txt]
         end
       endfunction
    
       function [data]=start_handl(data,el,attr)
         if el==data.tag then
           data.store=%t
         end
       endfunction
    
       function [data]=end_handl(data,el)
         if el==data.tag then
           data.store=%f
         end
       endfunction
    
       %ptr=XML_ParserCreate();
       XML_SetUserData(%ptr,'data');
       XML_SetElementHandler(%ptr,'start_handl','end_handl');
       XML_SetCharDataHandler(%ptr,'char_handl');
       XML_Parse(%ptr, txt);
     
       //display the value enclosed in xml tag 'PARAM_NAME'
       data.str
      

    See Also

    XML_ParserCreate,  XML_ParserFree,  XML_SetUserData,  XML_SetElementHandler,  XML_SetCharDataHandler,  XML_Conv2Latin,  XML_StopParser,  XML_ResumeParser,  

    Authors

    METALAU project-team, INRIA A.Layec

    Bibliography

    'The Expat XML Parser', Available: http://expat.sourceforge.net/