473,671 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parsing <content:encode d> through JS

Hello,

I am here after head-banging with this issue for several days. I am
trying to parse a feed using JS and have stucked on the
<content:encode d> tag. I have tried getElementsbyTa gName but its not
working.

Any suggstions?

Kashif

Apr 8 '06 #1
7 6696


kashaziz wrote:
I am here after head-banging with this issue for several days. I am
trying to parse a feed using JS and have stucked on the
<content:encode d> tag. I have tried getElementsbyTa gName but its not
working.


Is that well-formed XML with namespaces meaning content is a prefix and
declared e.g. with
xmlns:content=" http://example.org/2006/whatever"
?
Then with Mozilla and with Opera use e.g.

xmlDocument.get ElementsByTagNa meNS('http://example.org/2006/whatever',
'encoded')
instead of getElementsByTa gName.
For IE 6 and MSXML 3 you can use XPath e.g.
xmlDocument.set Property('Selec tionLanguage', 'XPath');
xmlDocument.set Property('Selec tionNamespaces' ,
'xmlns:content= "http://example.org/2006/whatever"');
var encodedElements = xmlDocument.sel ectNodes('//content:encoded ');

Both getElementsByTa gNameNS and selectNodes can also be called on
element nodes instead on on the document node. But note that selectNodes
takes an XPath expression, use a relative expression e.g.
element.selectN odes('content:e ncoded')
or
element.selectN odes('.//content:encoded ')
to find elements relative to the element the method is called on.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 8 '06 #2
Martin Honnen wrote:
kashaziz wrote:
I am here after head-banging with this issue for several days. I am
trying to parse a feed using JS and have stucked on the
<content:encode d> tag. I have tried getElementsbyTa gName but its not
working.


Is that well-formed XML with namespaces meaning content is a prefix and
declared e.g. with
xmlns:content=" http://example.org/2006/whatever"
?
Then with Mozilla and with Opera use e.g.

xmlDocument.get ElementsByTagNa meNS('http://example.org/2006/whatever',
'encoded')
instead of getElementsByTa gName.
For IE 6 and MSXML 3 you can use XPath e.g.
[...]


The Gecko DOM has XPath support, too.

<URL:http://xulplanet.com/references/objref/>
<URL:http://kb.mozillazine. org/XPath>
<URL:http://developer.mozil la.org/en/docs/XPath>
PointedEars
Apr 8 '06 #3


Thomas 'PointedEars' Lahn wrote:

The Gecko DOM has XPath support, too.


Right, Opera 9 will also implement the W3C DOM Level 3 XPath API (only a
W3C note, not a recommendation) but to access elements in namespaced
documents safely getElementsByTa gNameNS is sufficient and much easier to
use than the W3C DOM Level 3 XPath API.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 8 '06 #4
The Feed is:
<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="word press/1.5.2" -->
<rss version="2.0"
xmlns:content=" http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http ://wellformedweb.o rg/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"


<channel>
<title>Apnijobs .com: Jobs in Pakistan</title>
<link>http://www.apnijobs.co m</link>
<description>Wo rk for pleasure, not for creating more work - Search
Jobs in Pakistan and around the World.</description>
<pubDate>Mon, 27 Mar 2006 10:35:13 +0000</pubDate>
<generator>http ://wordpress.org/?v=1.5.2</generator>
<language>en</language>

<item>
<title>Teache rs Required for Nursery / Kindergarten and Junior School
(Karachi)</title>
<link>http://www.apnijobs.co m/teachers-required-for-nursery-kindergarten-and-junior-school-karachi.html</link>
<comments>htt p://www.apnijobs.co m/teachers-required-for-nursery-kindergarten-and-junior-school-karachi.html#co mments</comments>
<pubDate>Mon, 27 Mar 2006 10:34:17 +0000</pubDate>
<dc:creator>A li Asgher</dc:creator>

<category>Teach ing</category>
<category>Listi ng</category>
<category>Job s</category>
<guid>http://www.apnijobs.co m/teachers-required-for-nursery-kindergarten-and-junior-school-karachi.html</guid>
<description> <![CDATA[<p>School of excellence requires teachers for
Nursery / Kindergarten and Junior school Science teach...</p>
]]></description>
<content:encode d><![CDATA[<p>School of excellence requires teachers
for Nursery / Kindergarten and Junior school Science teacher for
immediate appointment. </p>

<p>Contact 021-4981303, 4816345.</p>

<p>Address: D-2, Block-4, Gulshan-e-Iqbal, Karachi.</p>

<p>E-mail: so*@cyber.net.p k</p>
]]></content:encoded >
<wfw:commentRSS >http://www.apnijobs.co m/teachers-required-for-nursery-kindergarten-and-junior-school-karachi.html/feed/</wfw:commentRSS>
</item>
--------------------------------------------------------------------------------------------------------

and the code is:
for (var i=0; i<this.feeditem s.length; i++){
if(i==this.feed _id){
var feedfound=1
this.title[i]=this.feeditems[i].getElementsByT agName("title")[0].firstChild.nod eValue

this.link[i]=this.feeditems[i].getElementsByT agName("link")[0].firstChild.nod eValue

this.descriptio n[i]=this.feeditems[i].getElementsByT agName("descrip tion")[0].firstChild.nod eValue

this.pubdate[i]=this.feeditems[i].getElementsByT agName("pubDate ")[0].firstChild.nod eValue
tickercontent = "<a
href="+this.lin k[i]+">"+this.ti tle[i]+"</a>"+"<br/>"

}
}

Apr 8 '06 #5


kashaziz wrote:
The Feed is:
<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="word press/1.5.2" -->
<rss version="2.0"
xmlns:content=" http://purl.org/rss/1.0/modules/content/" <content:encode d><![CDATA[<p>School of excellence requires teachers
for Nursery / Kindergarten and Junior school Science teacher for
immediate appointment. </p>

<p>Contact 021-4981303, 4816345.</p>

<p>Address: D-2, Block-4, Gulshan-e-Iqbal, Karachi.</p>

<p>E-mail: so*@cyber.net.p k</p>
]]></content:encoded >


Then use the already suggested code, the above is XML with namespaces so
with Mozilla and Opera make use of the W3C DOM Level 2 namespace aware
methods like getElementsByTa gNameNS e.g.
var encodedElements = xmlDocument.get ElementsByTagNa meNS(
'http://purl.org/rss/1.0/modules/content/',
'encoded'
);
Then you get a DOM NodeList the same as with getElementsByTa gName so you
should know how to loop through. Only note that the contents of those
content:encoded elements seems to be a single CDATA section node to
escape HTML markup snippets. You can read out that HTML markup snippets
as text (e.g. encodedElements[0].firstChild.dat a) but inside of a CDATA
section it will not be parsed into nodes.

And for IE 6/MSXML 3 you can use selectNodes and XPath 1.0 to get a DOM
NodeList as suggested
xmlDocument.set Property('Selec tionLanguage', 'XPath');
xmlDocument.set Property('Selec tionNamespaces' ,
'xmlns:content= "http://purl.org/rss/1.0/modules/content/"');
var encodedElements = xmlDocument.sel ectNodes('.//content:encoded ');
--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 9 '06 #6
I have tried var encodedElements = xmldata.getElem entsByTagNameNS (
"http://purl.org/rss/1.0/modules/content/", "encoded"); but it returns
a 0 length value.

Apr 11 '06 #7
Any suggestion guys?

Apr 20 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2955
by: Francesco Moi | last post by:
Hello. I'm trying to build a RSS feed for my website. It starts: ----------------//--------------------- <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd"> <rss version="0.91"> ----------------//----------------------
2
2314
by: Gill Bates | last post by:
I'm trying to login to a banking site (https://www.providentconnection.com) using vb.net. I've tried many variations of WebClient and HttpWebRequest; none of which I've got to work. My latest version is: Dim myWebClient As New WebClient Dim nvc As New NameValueCollection nvc.Add("Login", username) nvc.Add("Password", password)
17
2167
by: ccdrbrg | last post by:
This is a rather general subject, I apologize. I am new to XHTML, CSS, et al and I am having trouble understanding the DTD and xml namespace declarations. For example: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DT¬D/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
28
2938
by: dingbat | last post by:
I'm writing a "tabbed folder" nav bar. Site standards are graphical prettiness, CSS throughout, valid code, but accesibility is ignored where it conflicts with prettiness. The particular issue here is that the graphic designer wants a pretty (non-webbable) font on the shaded nav tabs, so I'm reduced to using bitmaps. To make the 4-way rollovers ("current" and "hover" states) work I'm using the standard "rollerblind" technique with a...
16
4904
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be easily verified: Implement the following in a web service method (just raises a SOAPException with a...
4
3024
by: David Lozzi | last post by:
Howdy, I'm using a WYSIWYG editor called TinyMCE. When I edit some text and then save it back to my SQL server using a SQLCommand, all HTML characters are changed to HTML code, i.e. &gt;strong&lt; instead of <strong> and so on. Is this a problem with the editor or something else? Does .Net convert it? I had to disable page validate request because of the tags, is there more? Thanks,
12
1555
by: Christian Roth | last post by:
Hello, I am merely asking this for my own understanding: Processing instruction's data part is not entity-aware, i.e. character and numercial entities are not resolved at parsing time. E.g., <?mypi &lt;par/&gt; ?> delivers as data part the String(!) "&lt;par/&gt;".
4
9074
by: SammyBar | last post by:
Hi all, I wonder is it possible to upload the content of an <imgfield to a server. The content of the <imgwas downloaded from a web site different from the one it should be uploaded. The image file should not be saved locally before uploading. It should not be visible any <input type=file on the form. How can it be done? I'm working on a project where client javascript requests an image server to generate dynamic images. The client...
5
14408
by: magix | last post by:
Hi, with: <Input type="file"...> it will let the user to click to "browse" button to browse for files, question is how can I limit the file type to be only jpg and gif extension, when the browse window open ? thank you.
0
8924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8823
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8602
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8672
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7441
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6234
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4412
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.