remuslazar / node-xmlsplit

Split large XML files into smaller chunks, uses Node.js Stream API
MIT License
18 stars 6 forks source link

Changing regex to allow nodes with prefixes #7

Closed 418error closed 6 years ago

418error commented 6 years ago

For your consideration. A very small change. When using the original code it was ignoring nodes with prefixes, such as:

<?xml version="1.0" encoding="UTF-8" ?>
<prefix:books xmlns:prefix="http://www.somesite.com/XMLSchema/ns/somesystem">
    <prefix:book ISBN="10-861003-324">
        <prefix:title>The Handmaid's Tale</title>
        <prefix:price>19.95</price>
    </prefix:book>
    <prefix:book ISBN="10-861003-324">
        <prefix:title>The Handmaid's Tale</title>
        <prefix:price>19.95</price>
    </prefix:book>
</prefix:books>

Changing the regx from

/<(\w+)[>\s]/mg

to

/<([\w:]+)[>\s]/mg

now works for nodes with or without prefixes

remuslazar commented 6 years ago

looks good, thanks!