Changeset 5206 for pjproject/trunk


Ignore:
Timestamp:
Dec 3, 2015 11:43:58 AM (9 years ago)
Author:
nanang
Message:

Misc (re #1882): Added feature of CDATA content handling into XML parser.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/src/pjlib-util/xml.c

    r4537 r5206  
    131131 
    132132    /* Sub nodes. */ 
    133     while (*scanner->curptr == '<' && *(scanner->curptr+1) != '/') { 
     133    while (*scanner->curptr == '<' && *(scanner->curptr+1) != '/' 
     134                                   && *(scanner->curptr+1) != '!') 
     135    { 
    134136        pj_xml_node *sub_node = xml_parse_node(pool, scanner); 
    135137        pj_list_push_back( &node->node_head, sub_node ); 
     
    139141    if (!pj_scan_is_eof(scanner) && *scanner->curptr != '<') { 
    140142        pj_scan_get_until_ch(scanner, '<', &node->content); 
     143    } 
     144 
     145    /* CDATA content. */ 
     146    if (*scanner->curptr == '<' && *(scanner->curptr+1) == '!' && 
     147        pj_scan_strcmp(scanner, "<![CDATA[", 9) == 0) 
     148    { 
     149        pj_scan_advance_n(scanner, 9, PJ_FALSE); 
     150        pj_scan_get_until_ch(scanner, ']', &node->content); 
     151        while (pj_scan_strcmp(scanner, "]]>", 3)) { 
     152            pj_str_t dummy; 
     153            pj_scan_get_until_ch(scanner, ']', &dummy); 
     154        } 
     155        node->content.slen = scanner->curptr - node->content.ptr; 
     156        pj_scan_advance_n(scanner, 3, PJ_TRUE); 
    141157    } 
    142158 
Note: See TracChangeset for help on using the changeset viewer.