开发者

Escape XML special chars in AJAX

I have an XML document which contains some invalid characters (é for example). Unfortunalty I cannot change the source XML file, and the file must be read through AJAX. How can I escape these charact开发者_StackOverflow社区ers client side?

Much thanks,

Steve

EDIT:

$.ajax({
        type: "GET",
        url: "http://foo.com",


        dataType: "xml",
        success: function(xml) {
            $(xml).find('images').each(function(){
                $(this).find('pic').each(function() {
                    ...code...
                });

            });
        },
        error: function(XMLHttpRequest, textStatus, errorThrown){
            alert(textStatus);
        } 

    })


escape() and unescape() don't work for your architecture?


Probably you're looking for following xml processing instruction (PI):

<?xml version="1.0" encoding="ISO-8859-1"?>

EDIT 1: client-side solution:

Can you read that xml content as string? If yes, replace existing PI by that above and .loadXML()

EDIT 2: Consider this link Specifying the Data Type for AJAX Requests


I sovled this one my self by convincing the admins for properly format their XML files. Once they removed/fixed the special characters, the problem was solved

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜