Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

xml.trim is not a function #20

Open
dcsan opened this issue Aug 2, 2016 · 1 comment
Open

xml.trim is not a function #20

dcsan opened this issue Aug 2, 2016 · 1 comment

Comments

@dcsan
Copy link

dcsan commented Aug 2, 2016

getting this error on trying to parse a file:

/Users/dc/dev/rikai/botmaker/oped/node_modules/xml-parser/index.js:23
  xml = xml.trim();
            ^

TypeError: xml.trim is not a function
    at parse (/Users/dc/dev/rikai/botmaker/oped/node_modules/xml-parser/index.js:23:13)
    at Object.<anonymous> (/Users/dc/dev/rikai/botmaker/oped/outliner.js:6:11)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:142:18)
    at node.js:939:3

its an OPML file like this:

<?xml version="1.0"?>
<opml version="2.0">
  <head>
    <title>My First Outline</title>
    <ownerTwitterScreenName>dcsan</ownerTwitterScreenName>
    <ownerName>david 'DC' collier</ownerName>
    <ownerId>http://twitter.com/dcsan</ownerId>
    <dateModified>Tue, 02 Aug 2016 05:04:30 GMT</dateModified>
    <expansionState>1,3</expansionState>
    <lastCursor>0</lastCursor>
    </head>
  <body>
    <outline text="stuff:">
      <outline text="text: here" created="Tue, 02 Aug 2016 03:17:55 GMT"/>
      <outline text="answers:" created="Tue, 02 Aug 2016 03:18:01 GMT">
        <outline text="two" created="Tue, 02 Aug 2016 03:18:06 GMT"/>
        <outline text="three" created="Tue, 02 Aug 2016 03:18:07 GMT"/>
        </outline>
      <outline text="one" created="Tue, 02 Aug 2016 03:18:05 GMT"/>
    </outline>
  </body>
</opml>
@ya-kostik
Copy link

ya-kostik commented Aug 5, 2016

Hello, I think this may have happened because you gave Buffer instead of a String. Try to convert buffer to a string or read a file as UTF-8

const xml = fs.readFileSync('./my.xml', 'utf8');

mk-pmb added a commit to mk-pmb/xml-parser-fix-pmb that referenced this issue Jan 2, 2017
mk-pmb added a commit to mk-pmb/xml-parser-fix-pmb that referenced this issue Jan 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants