开发者

Trouble parsing xml with jQuery on a extension for google chrome

开发者 https://www.devze.com 2023-01-22 03:37 出处:网络
I really can\'t figure out, what\'s wrong with this code: This is my manifest.json file: { \"name\": \"Test!\",

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?

0

精彩评论

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