Skip to content

amdwit/replace-xml-text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

replace-xml-text

Replaces text in text nodes of xml or html.

Installing

npm install replace-xml-text

How to use

the first argument are nodes from htmlparser2

the second argument can be string or RegExp

the third argument can be a function like for String.prototype.replace

Example

var replaceXmlText = require("replace-xml-text");
var {parseDOM} = require('htmlparser2');
var {default:render} = require('dom-serializer/lib');

const text='<html><body><p><span><span>a</span>b</span>c</html>';
const xml=parseDOM(text);
replaceXmlText.replace(xml,'abc','def');
const result=render(xml);
console.log(result);

About

replace a string in text nodes of xml or html

Resources

Stars

Watchers

Forks

Packages

No packages published