Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. const fs = require('fs');
  2. const parser = require('xml2json');
  3. const xml = 'xml/scm-14411970859060449.xml';
  4.  
  5. fs.readFile(xml, (err, data) => {
  6. if (err) console.log(err);
  7. let json = parser.toJson(data);
  8. // json = JSON.parse(json)
  9. fs.writeFile('./output.txt', json, (err) => {
  10. if (err) console.log(err);
  11. });
  12. let Json = JSON.parse(json);
  13. // console.log(Json);
  14. // for (let key in Json) {
  15. // console.log(Json[key]);
  16. // }
  17. // console.log(Json["com.xiriuz.sema.xml.schillerEDI.SchillerEDI"]);
  18. // for (key in Json["com.xiriuz.sema.xml.schillerEDI.SchillerEDI"]) {
  19. // console.log(key);
  20. // }
  21. console.log(Json["com.xiriuz.sema.xml.schillerEDI.SchillerEDI"].patdata.lastname);
  22. });
  23.  
  24. // com.xiriuz.sema.xml.schillerEDI.SchillerEDI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement