-
-
Save enricopolanski/110e8edf62d03cb8e3b9c3b29e9ff6d1 to your computer and use it in GitHub Desktop.
Revisions
-
jkantr revised this gist
Nov 30, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,5 +24,5 @@ module.exports = (mypath) => { console.log("Relationships parsed successfully") } return relationship_object; }); -
jkantr revised this gist
Nov 30, 2017 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,5 @@ module.exports = (mypath) => { console.log("Relationships parsed successfully") } return JSON.stringify(relationship_object); }); -
jkantr revised this gist
Nov 30, 2017 . 2 changed files with 20 additions and 35 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,31 +1,30 @@ var fs = require("fs"); var path = require("path"); var cheerio = require("cheerio"); module.exports = (mypath) => { var inputFile = fs.readFileSync(mypath, "utf8"); var $ = cheerio.load(inputFile, {xmlMode:true}); // defines the selector var relationship_number = $("Relationship").filter("[Id]").length; // Initialize an empty object var relationship_object = {}; // loops over the relationship xml in order to find the relationship Id and the target // and adds the value to the relationship_object for (i=0; i < relationship_number; i++){ relationship_object[$("Relationship").filter("[Id]")[i].attribs.Id] = $("Relationship").filter("[Id]")[i].attribs.Target; } // gets a confirmation in console of correct parsing if(Object.keys(relationship_object).length===relationship_number){ console.log("Relationships parsed successfully") } relationship_json = JSON.stringify(relationship_object); console.log(relationship_json); }); -
enricopolanski created this gist
Nov 30, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ var parseFile = require("./jsxmlparser.js"); // ReferenceError: mypath is not defined // at Object.<anonymous> (C:\Users\Aquazi\Desktop\Traducee\jsxmlparser.js:4:17) // // at Module._compile (module.js:624:30) // at Object.Module._extensions..js (module.js:635:10) // at Module.load (module.js:545:32) // at tryModuleLoad (module.js:508:12) // at Function.Module._load (module.js:500:3) // at Module.require (module.js:568:17) // at require (internal/module.js:11:18) // at repl:1:17 // at ContextifyScript.Script.runInThisContext (vm.js:50:33) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ var fs = require("fs"); var path = require("path"); module.exports=(mypath); var inputFile = fs.readFileSync(mypath, "utf8"); var cheerio = require("cheerio"); var $ = cheerio.load(inputFile, {xmlMode:true}); // defines the selector var relationship_number = $("Relationship").filter("[Id]").length; // Initialize an empty object var relationship_object = {}; // loops over the relationship xml in order to find the relationship Id and the target // and adds the value to the relationship_object for (i=0; i < relationship_number; i++){ relationship_object[$("Relationship").filter("[Id]")[i].attribs.Id] = $("Relationship").filter("[Id]")[i].attribs.Target; } // gets a confirmation in console of correct parsing if(Object.keys(relationship_object).length===relationship_number){ console.log("Relationships parsed successfully") } relationship_json = JSON.stringify(relationship_object); console.log(relationship_json);