开发者

How do I get the innertext value of a non-text XML RSS node using jQuery and/or javascript?

开发者 https://www.devze.com 2023-04-13 04:59 出处:网络
Here\'s the RSS/XML node (it\'s from my- picasaweb album feed): <gphoto:name>NurseryRenovation</gphoto:name>

Here's the RSS/XML node (it's from my - picasaweb album feed):

<gphoto:name>NurseryRenovation</gphoto:name>

I'm trying to get the "NurseryRenovation" text from inside the node using jQuery. Here's my code:

var itemTitle = $item.find("gphoto:name").val();

That returns "undefined" as does using .textContent, .innertext, and .innerxml. Using .text() returns an empty string. Using .contents returns what appears to be the inner workings of the "find()" method. Using $item.attr("gphoto:name") also returns "undefined". How can I get the inner content of the "gphoto开发者_StackOverflow社区:name" node using jQuery? This is driving me nuts!


To grab tags that use colons, you have to escape the colons:

$('gphoto\\:name')

Selecting non-standard tag with jQuery

That was what primary problem with what you were doing. After that, you really should look at the documentation for the different jQuery methods you mentioned.

.text() would seem to me to give you what you are looking for; the other functions can provide you different things. [ffr .val() is aimed at <form> elements, not content nodes]

0

精彩评论

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