Bug Tracker

Modify

Ticket #3943 (closed bug: invalid)

Opened 5 years ago

Last modified 5 years ago

Parsing xml from hiddenField

Reported by: Qusai Owned by:
Priority: major Milestone: 1.3
Component: unfiled Version: 1.3
Keywords: Cc:
Blocking: Blocked by:

Description

Hi, First, Thanks for the help. I am storing xml in a hidden field which is going to be updated by some user actions. I need the xml changes to be reflected in an unsorted list so I am using jquery to do that. The code works in Firefox but not IE. Following is a sample of the code. Thanks for the help again.

<!DOCTYPE html PUBLIC "-W3C DTD HTML 4.01EN"

" http://www.w3.org/TR/html4/strict.dtd">

<html> <head>

<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <title>Address book</title>

<script src="jquery-1.3.js" type="text/javascript"></script>

<script type="text/javascript">

function MyFunc() {

var xml = document.getElementById('myHiddenField').value; $(unescape(xml)).find('MediaAssetInfoLite').each(function() {

var title = $(this).find('Title').text(); var url = $(this).find('Uri').text(); $('<li></li>').html('<a href=\"' + url + '\">' + title + '</a>').appendTo('#target');

});

}

</script>

</head> <body>

<div id='update-target'>

<a href="javascript:MyFunc();">Click here to load addresses</a> <ul id="target"> </ul> <input id="myHiddenField" type="hidden" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?>

&lt;ArrayOfMediaAssetInfoLite xmlns:i=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; > &lt;MediaAssetInfoLite> &lt;Title>object13_t&lt;/Title> &lt;Uri> http://localhost/Assets/object13_t.jpg&lt;/Uri> &lt;/MediaAssetInfoLite> &lt;MediaAssetInfoLite> &lt;Title>pc0134a_collectItem&lt;/Title> &lt;Uri> http://localhost/Assets/pc0134a_collectItem.png&lt;/Uri> &lt;/MediaAssetInfoLite> &lt;MediaAssetInfoLite> &lt;Title>pc0134a_display&lt;/Title> &lt;Uri> http://localhost/Assets/pc0134a_display.png&lt;/Uri> &lt;/MediaAssetInfoLite> &lt;/ArrayOfMediaAssetInfoLite>"

/>

</div>

</body> </html>

Change History

comment:1 Changed 5 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

The $(html) operation can't be used to parse xml. Use an xml parser instead.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.