XML : How to Reference XML File/Data to be Used with HTML and jQuery?

So I have an XML file, that I generated from an Excel file. Each item looks like this:

  <item>      <partnum>pn0001</partnum>      <category>Parent Category</category>      <title>Item Name Here</title>      <type>T27</type>      <diameter>6"</diameter>      <width>0.045"</width>      <arbor>7/8"</arbor>      <material>Metal</material>      <maxrpm>13300</maxrpm>      <tool>Angle Grinder</tool>      <purpose>Cutting</purpose>      <brand>Brand Name Here</brand>      <imgsrc>localfolder\file.jpg</imgsrc>  </item>    

I'd like to be able to reference this data, and create variables for each of the items. Obviously, I'll have to write a loop that will go through each item, and store the data. It will end up being something like pn0001.category, pn0001.title. etc, etc.

My question is: how do I begin to reference the XML file? I ran across this link: https://api.jquery.com/jQuery.parseXML/

Which is great, but in the code, you'll see that they have the XML data hard-coded as a string in the first variable.

Basically, how do I get the data from the XML into variables in either Javascript or jQuery?

No comments:

Post a Comment