libxml2 tree: NULL vs empty string
In libxml2, C calls
xmlNewPI("name", NULL);
xmlNewPI("name", "");
produce the following processing instructions
<?name?> <?name ?>
(notice the space in the second case). At the first moment I though that I shouldn't allow the first variant. But then reminded that in XML absence of node and empty node are sometimes very different things. So let both variants be.
Then I tested two variants for another node type:
xmlNewComment(NULL);
xmlNewComment("");
The second case produced the expected result
<---->
but the first variant seems broken. In serialized XML, I have no comments at all!
Anyway, I decided to have difference between nothing and empty string. I feel it can be used somehow,
Vibe code with your voice
Stop fighting speech recognition.
Just talk → fix mistakes later
"... _brings_ hello world" ❌
↓
"... _prints_ hello world" ✅
Categories:
Generative XML