Skip to content

Does not handle processing instructions #30

@pecostm32

Description

@pecostm32

Next to not handling comments it also does not recognize processing instructions.

An easy way to overcome this is to use a do while loop in the node parsing like so:
//Need a do while loop to find a proper top tag and allow skipping of processing instructions or comments
do
{
/* Parse open tag
*/
tag_open = xml_parse_tag_open(parser);

if (!tag_open)
{
  xml_parser_error(parser, NO_CHARACTER, "xml_parse_node::tag_open");
  goto exit_failure;
}

original_length = tag_open->length;
attributes = xml_find_attributes(parser, tag_open);

//Check if the tag is a processing instruction or a comment
if((tag_open->length > 0) && ('?' == tag_open->buffer[0]) || (('!' == tag_open->buffer[0]) && ('-' == tag_open->buffer[1]) && ('-' == tag_open->buffer[2])))
{
  //Drop the found processing instruction or comment
  xml_string_free(tag_open);

  //Reset the tag_open pointer to force scanning for the next one
  tag_open = 0;
  
  if(attributes)
  {
    //Need to free attributes!!!!!! also in error handling!!!!! 
  }
}

} while(!tag_open);

Another issue is the freeing of the attributes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions