XML : Get Full Content of XML Item?

I have an XML file that has items that look like this:

  <CutOffItem>      <partnum>SAIT22021</partnum>      <diameter>4-1/2"</diameter>      <width>0.045"</width>      <arbor>7/8"</arbor><material>METAL</material>      <maxrpm>13300</maxrpm>      <brand>UNITED ABRASIVES, INC.</brand>          <imgsrc>style\images\Original Bolt Pics\Abrasives\Cutoff\SAIT 4.5-8in.jpg</imgsrc>  </CutOffItem>    

I am referencing each element via jQuery to use in an HTML document like this:

  xmlDoc = $.parseXML( xml ),  $xml = $( xmlDoc ),  $partnum = $xml.find( "partnum" );  $title = $xml.find( "title" );  $category = $xml.find( "category" );  $type = $xml.find( "type" );  $diameter = $xml.find( "diameter" );  $width = $xml.find( "width" );  $arbor = $xml.find( "arbor" );  $brand = $xml.find( "brand" );  $imgsrc = $xml.find( "imgsrc" );    

And displaying them like this:

  //Title  var h3 = document.createElement('p');  h3.innerHTML = $title.text();  $('#item').append(h3);    

All is working as intended, but when I try to do this to the img src:

  // IMG  var img = document.createElement('img');  var src = document.createAttribute('src');  src.value = $imgsrc.text();  img.setAttributeNode(src);  $('#item').append(img);    

The img element that displays on the HTML page code looks like this:

  <img src="styleimagesOriginal Bolt PicsAbrasivesCutoffSAIT 4.5-8in.jpg">    

.text() removed all forward slashes from the URL. How can I keep the forward slashes?

No comments:

Post a Comment