Trouble parsing xml with jQuery on a extension for google chrome
I really can't figure out, what's wrong with this code:
This is my manifest.json file:
{
"name": "Test!",
"version": "1.0",
"de开发者_运维知识库scription": "Testing this",
"content_scripts": [ {
"js": [ "jquery-1.4.2.min.js", "parser.js" ],
"matches": [ "file:///*/*" ]
} ],
"permissions": [
"tabs",
"http://*/*"
]
}
Here is parser.js file
var xmlcontent = "<?xml version=\"1.0\" encoding=\"utf-8\"?><A><B><C>Hey</C></B></A>";
var doc = $(xmlcontent).find('C').text();
This simple script, throws the following error:
Uncaught TypeError: Cannot read property 'childNodes' of null
Can anyone help me?
This works for me here:
http://jsfiddle.net/Y9mPM/
Are you sure you have access to jQuery from this environment?
精彩评论