473,748 Members | 6,037 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stop XmlDocument.Loa d() from using cached data?

Is there any way to stop an XmlDocument object from using data grabbed
from a previous request?

e.g. if I used XmlDocument.Loa d to grab a URI, and I know that this
URI changes often (for example, an RSS feed) can I somehow tell the
framework to not use cached data?

Will I have to create a custom HttpWebRequest and convert the data to
an XmlDocument for processing or is there some way to tell XmlDocument
(perhaps via the XmlResolver somehow?) to never use the cache?

Thanks.
Jun 27 '08 #1
5 3718

"Mahmoud Al-Qudsi" <mq****@gmail.c omwrote in message
news:e1******** *************** ***********@y21 g2000hsf.google groups.com...
Is there any way to stop an XmlDocument object from using data grabbed
from a previous request?

e.g. if I used XmlDocument.Loa d to grab a URI, and I know that this
URI changes often (for example, an RSS feed) can I somehow tell the
framework to not use cached data?

Will I have to create a custom HttpWebRequest and convert the data to
an XmlDocument for processing or is there some way to tell XmlDocument
(perhaps via the XmlResolver somehow?) to never use the cache?
The Load method honors the WebRequest Caching policy which by default is set
to bypass the cache. However its worth noting that this actually means
bypass the local cache it does not add a pragma: no-cache header to the
request and therefore other caches such as a proxy server between the client
and the origin server may serve content from a cache.

You will need to use HttpWebRequest if the default behaviour (or your
prevailing settings set via the requestCaching element in the .config(s)) is
not want you need.

I suggest you use a policy created wth Revalidate level.
--
Anthony Jones - MVP ASP/ASP.NET
Jun 27 '08 #2
You will need to use HttpWebRequest if the default behaviour (or your
prevailing settings set via the requestCaching element in the .config(s)) is
not want you need.

I suggest you use a policy created wth Revalidate level.
I take it this will this do the trick then?

.....
WebRequest.Defa ultCachePolicy = new
RequestCachePol icy(RequestCach eLevel.Revalida te);
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Loa d(myUri);
Jun 27 '08 #3
"Mahmoud Al-Qudsi" <mq****@gmail.c omwrote in message
news:6c******** *************** ***********@t54 g2000hsg.google groups.com...
>
You will need to use HttpWebRequest if the default behaviour (or your
prevailing settings set via the requestCaching element in the
..config(s)) is
not want you need.

I suggest you use a policy created wth Revalidate level.

I take it this will this do the trick then?

....
WebRequest.Defa ultCachePolicy = new
RequestCachePol icy(RequestCach eLevel.Revalida te);
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Loa d(myUri);
Assuming you don't have a conflicting setting in the application's config(s)
then yes that should do it.
--
Anthony Jones - MVP ASP/ASP.NET
Jun 27 '08 #4
Assuming you don't have a conflicting setting in the application's config(s)
then yes that should do it.
Thanks, it worked great.
Jun 27 '08 #5
"Mahmoud Al-Qudsi" <mq****@gmail.c omwrote in message
news:11******** *************** ***********@m3g 2000hsc.googleg roups.com...
>
Assuming you don't have a conflicting setting in the application's
config(s)
then yes that should do it.

Thanks, it worked great.
Perhaps I should have mentioned in response to your previous reply that
modifying the DefaultCachePol icy as you are doing there affects _all_ Web
Client code. This may have some un-wanted side effects in previously
working code.

Since any code in the app domain can muck about with the DefaultCachePol icy
its actually not a good idea to change it or rely on it. I think the best
approach is to use an instance of HttpWebRequest and set the policy of that
instance.

--
Anthony Jones - MVP ASP/ASP.NET
Jun 27 '08 #6

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

Similar topics

2
6848
by: Gustaf Liljegren | last post by:
I need to merge several XML files into one large. All of them has a DOCTYPE tag, but the SYSTEM identifier points to a DTD that doesn't exist. (I use the PUBLIC identifier with catalog files, so the SYSTEM identifiers has no purpose in my application.) Anyway, when I load each document, using XmlDocument.Load(file), I get a FileNotFoundException, because of the DTD pointer in the SYSTEM identifier. I'd rather skip all the entity...
1
3550
by: Chief | last post by:
I am unable to load an xml document that contains Chinese characters in an attribute value. I need to load the document into and XmlDocument object and am using the XmlDocument.Load(string filename) method. I get an error that says the document contains invalid characters. The document loads fine with Chinese characters in a node value, but not in an attribute value. I have tried setting the encoding to UTF-8 and UTF-16, but neither solve...
1
4301
by: John A Grandy | last post by:
I've got an app that has hundreds of medium-sized (100s of elements) XML files on disk (not in db). Right now these are loaded via XMLDocument.Load and searched with XPATH. The performance has become unacceptable. Performance improvment strategies I know of: 1. Switching to XMLReader
11
10177
by: bleedledeep | last post by:
I've been tracking down a memory leak using DevPartner 7.2 and what I am seeing is that calling XmlDocument.Load() leaks A LOT of memory. The following code is called when I click a button on my test form. (this is test code I wrote to confirm the bug, not my actual code) private void button1_Click(object sender, System.EventArgs e) { XmlDocument xd = new XmlDocument();
2
1858
by: supercodepoet | last post by:
I have cXml document I want to load to parse. The document has a DOCTYPE element that points to an external dtd via http. When the document loads it trys a web request which I am assuming is to get the dtd. We have a proxy and this throws and exception when trying to load the document becuase it could not authenticate through the proxy. Is there anyway I can turn off the download?
10
13975
by: lamxing | last post by:
Dear all, I've spent a long time to try to get the xmldocument.load method to handle UTF-8 characters, but no luck. Every time it loads a document contains european characters (such as the one below, output from google map API), it always said invalid character at position 229, which I believe is the "ß" character. Can anyone point me to the right direction of how to load such documents using the xmldocument.load() method, or...
4
1702
by: DanThMan | last post by:
The following code works when I debug and when I install the software and run the .exe, but if I try to open the form in the designer (which causes this code to run), I get an error: Private Sub LoadTestSettings() Dim rootPath As String Dim eventHandler As ValidationEventHandler rootPath = My.Application.Info.DirectoryPath eventHandler = New ValidationEventHandler(AddressOf XmlValidationEventHandler)
0
1044
by: nano2k | last post by:
Hi Is it possible to find out the output size of an XmlDocument object? I mean, a good-enough approach is this: XmlDocument doc = new XmlDocument(); // load data in doc int length = doc.OuterXml.Length; 1.Advantages: 1.1. It's an approximate value, but the approximation is very good, so I put this as an advantage
1
3081
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
The description of the XMLDocument.Load method doesn't quite answer the question. When passing in a FileStream object to the Load method, does it load the entire document into memory? For example, if I have a 1 gigabyte file, would the Load method attempt read the entire 1 gigabyte file into memory when using a FileStream object?
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9372
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
9324
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
8243
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
6796
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
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
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.