简体   繁体   中英

How to remove whitespaces between elements/nodes in XML using libxml in C?

I have sample xml request:

<?XML VERSION="1.0" ENCODING="UTF-8" STANDALONE="YES"?>
 <ELEMENT ATTRIBUTE="TEST">
    <CHILDREN>ABCDE</CHILDREN>
    <CHILDREN>MNOPQR</CHILDREN>
  </ELEMENT>

I have noticed that libxml considering the spaces between elements or childern nodes(ie between > and < ). Libxml homepage says In XML all characters in the content of the document are significant including blanks and formatting line breaks . Is there a way handle these kind of requests.

XML_PARSE_NOBLANKS option might be what you need:

XML_PARSE_NOBLANKS = 256 : remove blank nodes

Found it myself, if we need to check on the XML node type ( type is a property of the XML node). In this case if nodetype != XML_ELEMENT_NODE then skip the node.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM