I have searched the documentation at https://github.com/polotek/libxmljs/wiki but fails to find out how to create plain text nodes.
Here is my node.js code:
var libxmljs = require('libxmljs');
var xmlStr = '<div><p>bar <strong>foo</strong></p></div>';
var doc = libxmljs.parseXmlString(xmlStr);
// Create a normal extra node
doc.get('/div/p').node('span', 'foobar');
doc.toString() now results in:
<?xml version="1.0" encoding="UTF-8"?>
<div>
<p>bar <strong>foo</strong><span>foobar</span></p>
</div>
But what if I wanted:
<?xml version="1.0" encoding="UTF-8"?>
<div>
<p>bar <strong>foo</strong> foobar</p>
</div>
I am aware that I can set the content of a node with .text(), so I COULD do this by getting the string content of <p>, append it as a string and re-set it with .text() again. That is not what I need. I need to create a text node in the DOM.
Is this not possible, or am I just to bad at reading the docs?