Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save luismendes070/9159064d4e6ccc6b9bb2c3ceacde2b95 to your computer and use it in GitHub Desktop.
Save luismendes070/9159064d4e6ccc6b9bb2c3ceacde2b95 to your computer and use it in GitHub Desktop.
TypesScript programming language XML file reader XML file writer feature #ChatGPT
import * as fs from 'fs';
import * as xml2js from 'xml2js';
// Read the XML file
const xml = fs.readFileSync('file.xml', 'utf-8');
// Convert the XML to a JavaScript object
xml2js.parseString(xml, (err, result) => {
if (err) {
console.error(err);
return;
}
// Do something with the result object
console.log(result);
});
@luismendes070
Copy link
Author

<h2>Books</h2>
<ul>
  <li *ngFor="let book of books">
    {{ book.title }} by {{ book.author }} ({{ book.year }})
  </li>
</ul>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment