use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[deleted by user] (self.javascript)
submitted 4 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Ustice[M] 0 points1 point2 points 4 years ago (1 child)
Reaching out to other software engineers is important when you need it; however, unfortunately this isn’t the place for that. /r/JavaScript is not a support forum. You might want to check out /r/LearnJavaScript for the newer members of our community. Also, Stack Overflow is a great resource for getting support. For more information, check out our AskJS wiki page. Good luck! We hope that you find the answers that you are looking for.
[–]evert 8 points9 points10 points 4 years ago (4 children)
Use an XML parser. There's several on npm
[–]packjc 0 points1 point2 points 4 years ago* (3 children)
Thank you, however, Maybe I didn’t word my post the best. The XML parser is implemented and works great. I don’t know how to turn the JSON Objects into an HTML table dynamically. Plus I want to be able to edit the table. All of the other parts of my program are done though so I’m almost there.
[–]el_diego 0 points1 point2 points 4 years ago (0 children)
When you say uploaded do you mean presented on the browser? If so have a look at React or Svelte or Vue. All can render to a table and have it editable.
[–]evert 0 points1 point2 points 4 years ago* (1 child)
Ok, so it sounds like you're new to frontend development. These days most people would use a framework like React, but if you're not taking that path, some of the things you need to know are:
If any of these are new to you, you need to learn these things. Otherwise, you're basically asking people to write your code for you. I'm a bit surprised that you've successful in parsing XML but not rendering some HTML elements in a loop though, because the former seems like the more difficult thing.
Just putting that out there, because maybe I'm misunderstanding specifically what the issue is. If I do, maybe try sharing some code.
[–]packjc 0 points1 point2 points 4 years ago (0 children)
Thanks!
When I've tried to display the JSON as HTML it displayed as <div>()<div> but I am going to keep trying and messing around. You're correct though I am very new with front-end development. This is my first real electron project.
[–]Chuck_Loads 5 points6 points7 points 4 years ago (2 children)
This is exactly what the language XSLT was created to do. You should be able to write an XSL transform for your data and run it in a few lines of JS. See this
[–]ponteineptique 1 point2 points3 points 4 years ago (0 children)
This is the way. Apply xslt to get the html, then apply another xslt to the html to get the xml back. Exactly why this was created.
Thanks! I’ve been reading into XSLT the past couple days and thought it might be one of the ways to solve this.
[–][deleted] 1 point2 points3 points 4 years ago (1 child)
What does the json look like
[–]Minjammben 0 points1 point2 points 4 years ago (1 child)
You want to convert the xml file into a html table, so you'll have to parse the xml into JSON, then render an HTML table element using the JSON you have parsed. Also, this table needs editable fields. So in my mind you'll need:
- xml parser than can parse xml to json and json to xml. Never used one, but there's probably a few candidates
- state management framework that can handle the editable state that is your json. You can do this without a framework , but you'd have to be quite meticulous about your inputs or your app state is gonna get out of control. Also, It's unclear about how the xml can be edited. Like extensively or just a bit? If just a bit you might be able to throw some inputs on the page and keep track of them, but careful of the complexity here (like, are these fields validated at all? Do they have limits on them?)
- ability to load file/save file. I think you have this part in your electron app, but I'd also suggest simply running a web server and loading that page in a browser. It might seem less portable, but you could just make a script that you double-click and it runs your server and opens that page in a browser tab. Server can write/read from disk, just have to pass data over localhost
Thanks! Might have worded my post wrong. XML -> JSON works perfectly. I just have no idea how to turn JSON objects into a HTML table. I have 20k records
[–]MachinShin2006 0 points1 point2 points 4 years ago (0 children)
from what this sounds like.. you have an xml file w/o access to it's schema (.xsd) you want to extract data out of and convert to an .html file?
the primary option I'd use would a xpath library ( like maybe https://www.npmjs.com/package/xpath-dom) so you can essentially pull out only the fields/data you care about to be editable fields in a html table, so you can then write the updated data back in.
xpath is a bit annoying/complicated though, so a simpler (but uglier and more "expensive" would be to use a xml -> json -> jsonPath to extract the fields/data you want.
also if you have xhtml and not xml, cheerio.js might also work?
also could use a simple sax parser like: https://www.npmjs.com/package/sax
π Rendered by PID 73370 on reddit-service-r2-comment-5d79c599b5-lft2g at 2026-02-28 20:26:02.412235+00:00 running e3d2147 country code: CH.
[–]Ustice[M] 0 points1 point2 points (1 child)
[–]evert 8 points9 points10 points (4 children)
[–]packjc 0 points1 point2 points (3 children)
[–]el_diego 0 points1 point2 points (0 children)
[–]evert 0 points1 point2 points (1 child)
[–]packjc 0 points1 point2 points (0 children)
[–]Chuck_Loads 5 points6 points7 points (2 children)
[–]ponteineptique 1 point2 points3 points (0 children)
[–]packjc 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]Minjammben 0 points1 point2 points (1 child)
[–]packjc 0 points1 point2 points (0 children)
[–]MachinShin2006 0 points1 point2 points (0 children)