Skip to content

parsing nodes that are not always present #558

Answered by siriusdemon
DavidePatria asked this question in Q&A
Discussion options

You must be logged in to vote

According to the document.
There is a special value of xml_node type, known as null node or empty node. It does not correspond to any node in any document, and thus resembles null pointer. However, all operations are defined on empty nodes; generally the operations don’t do anything and return empty nodes/attributes or empty strings as their result. This is useful for chaining calls; i.e. you can get the grandparent of a node like so: node.parent().parent(); if a node is a null node or it does not have a parent, the first parent() call returns null node; the second parent() call then also returns null node, so you don’t have to check for errors twice. You can test if a handle is null via …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DavidePatria
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants