473,394 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Reading part of contents from other page via XMLHttpRequest

JP
Hello,

I am trying to figure out how can I read particular content of the page
after I have requested page into XMLHttpRequest object.
Is there a way to parse somehow responseText? In pseudo code I want to
do something like this.

var myHeader = myXMLHttpRequest.document.getElementById("Header") ;

May 13 '06 #1
4 1704


JP wrote:
I am trying to figure out how can I read particular content of the page
after I have requested page into XMLHttpRequest object.
Is there a way to parse somehow responseText? In pseudo code I want to
do something like this.

var myHeader = myXMLHttpRequest.document.getElementById("Header") ;


If you load an XML document then you have
myXMLHttpRequest.responseXML
as a document and you can use the W3C Core DOM on that. getElementById
in XML documents works only if the document type definition defines
attributes of type ID.

--

Martin Honnen
http://JavaScript.FAQTs.com/
May 14 '06 #2

"JP" <jp*******@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hello,

I am trying to figure out how can I read particular content of the page
after I have requested page into XMLHttpRequest object.
Is there a way to parse somehow responseText? In pseudo code I want to
do something like this.

var myHeader = myXMLHttpRequest.document.getElementById("Header") ;


Try putting in a hidden iframe:

<iframe id="myXMLHttpIframe" style="display:none;">
...
myXMLHttpIframe.document.body.innerHTML =
myXMLHttpRequest..responseText;
myHeader = myXMLHttpIframe.document.body.getElementById("Head er");
May 14 '06 #3
JP
Thanks for reply.
Seems like IFRAME is the only solution. I was quite suprise that I
cannot parse outputting HTML.
It would be nice if there would be responseHTML which would be document
object of the xmlHttprequest.

May 14 '06 #4
JP wrote:
I am trying to figure out how can I read particular content of the page
after I have requested page into XMLHttpRequest object.
Is there a way to parse somehow responseText? In pseudo code I want to
do something like this.

var myHeader = myXMLHttpRequest.document.getElementById("Header") ;


Provided your HTML element has an `id' attribute of type ID and
value "Header", you could do something along

var m = myXMLHttpRequest.responseText.match(
/<[^>]+\s+id\s*=(["']|\s*)Header(["'])(\s+[^>])*>/i);

However, outputting X(HT)ML as application/(xhtml+)xml and using
a parser object or responseXML instead is the sane approach.
PointedEars
--
Those who desire to give up freedom in order to gain security,
will not have, nor do they deserve, either one.
-- Benjamin Franklin
May 22 '06 #5

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

Similar topics

1
by: Marcin Okraszewski | last post by:
Hi, I would like to include one page inside an other page, almost like a IFRAME does it. The problem is that I would like the included part to occupy as much space as it needs, so it would be...
2
by: Kevin Morgan | last post by:
I'm trying to write a widget for Mac OSX Tiger. Here's the problem: The user enters a search term which is sent to a perl script on a remote server. This script returns a fully formatted HTML page....
6
by: evanburen | last post by:
Is it possible to refresh only part of a page rather than reload the entire thing? I have dropdown box that's populated from a database using ASP that I need refreshed but I don't want to reload...
1
by: sam | last post by:
Hi, I know fragment caching where you can use a cached user control in a non-cached page (or the opposite) But without using a user control, how can I cache just a part of my page (two...
22
by: PSN | last post by:
Hi all, Can some one help me if it is possible to refresh a part of a page, without reloading the whole page. Let's say, i want to add a small message box to my webpage. After writing a message,...
3
by: Paul E Collins | last post by:
I want to skip the rendering of certain parts of a Web page if the user doesn't have a certain permission (e.g. a cookie). I'd like to do it along these lines: <p>Anybody can see this...
6
by: John Kotuby | last post by:
Hi all, I am using a 3rd party program in a VS2005 web project. The tool takes as input a string containing HTML and converts it to RTF. I have been creating a page by dynamically loading...
4
by: Joe Kovac | last post by:
Hi! I would like to create a page, where the user can print the lower part of the page by pressing a button. It might look like this: ----------------------------------------------- o...
2
by: suma | last post by:
hi all... i have array and iwant this array to other page in URL let the name of array is numbers and i fill this array by loop from data base when i write this .. echo "<META...
0
by: frkem | last post by:
After virus infection (Sohanad 32) an I deleted all infected files my windows operating system is not working. Windows media player, search, help and support icon by double clicking it one message...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...

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.