I am trying to parse through the contents of an xml file resident on a remote server in visual basic 6.0 using the MSXML2.DOMDocument class.
I am using the Load method of the MSXML2.DOMDocument class to pass in the url. The url is of the form http://<server>/ABC.xml, however, the server requires user credentials for accessing the file.
How do I pass in user credentials using this class or another supporting class?
You can use http://<username>:<password>#<server>/ABC.xml in many cases, or you can use the XMLHTTPRequest helper object to make the actual requests.
Note that when you use an MSXML DOMDocument object you aren't parsing anything, the object does the heavy lifting. All you're doing is navigating the DOM tree, a trivial task by comparison.
Related
In my web api I allow the user to specify how they want their data via an extension: ie. host/api/location/getmyhouse.json or getmyhouse.xml.
However I also have actions that aren't get and they return if the action was successful or not. For that it doesn't really make sense to specify the return type so I was trying to have it just default to json. However by default it seems xml is used.
Is there a way to default the formatter to json vs xml without removing xml as a formatter AND without having the client specify it as I want this to be done via simple url in the browser. It's an internal thing so that's what we would like.
my Firefox addon shall add a search engine, that
provides suggestions
gets its search template URL specified on runtime (i.e.: template URL depends on the preferences of the user)
And I don't see a way to do both at the same time.
I see two options to add a search engine:
addEngineWithDetails
addEngine
addEngineWithDetails() allows me to add a search engine with the template URL. But it does (apparently?) not allow to provide a suggestions URL.
addEngine() allows me to add a search engine that is specified in an XML file. But if have that file saved locally in my addon directory (e.g. chrome://example-engine/content/search.xml), how can I change the template URL on runtime? And using an online XML is an unsafe options since the internet connection could be broken or bad during the addon install.
First fo all, you're right, addEngineWithDetails does not support suggestions.
The way to go would be to use addEngine (and removeEngine).
As for the "dynamic" part of your question: While I didn't test it, the implementation seems to happily accept data: URIs. So you could:
Construct a data URI using whatever methods you like (even constructing a full XML DOM and serializing it).
Call addEngine with the data URI.
When the user changes a pref, remove the old engine, and construct a new one.
Background: We are using grails 2.1.1. We are not using any DB as of now. We make a web service call for each response on another server.
Now the problem is, there is web service call which returns some static data in XML form and this data is usable throughout the application. The size of the xml is around 40kb. This xml contains static data like, project_list, status_type_list etc. and we have to use this in various dropdowns and menu items in different gsp pages.
So, please suggest us the best way to handle this data. So that it doesn't effect our page load time and browsing experience. And also we can easily use the data on client side.
responding to your comment on the question. I would prefer using annotation based caching over the plugin, if the requirement is as simple as you state that it is.
If the calls are being made from server-side and you want to cache the results of the parsed XML then you can do something like:
#Cacheable("staticDataCache")
def getStaticDataFromXML() {}
You can then use the above method to pull the maps, lists whatever data structure you've used to store the result and it will pull it from the cache.
and then another service method to flush the cache, which you can call frequently from a Job.
#CacheFlush("staticDataCache")
def flushStaticDataCache() {}
Use the cache plugin to cache the static xml data. And then add some policy as to when the cache should be updated... (i.e. using a job to check if the xml has changed every hour)
I have a file, sample.xml located at one web server. I want to access this file from a GWT application running at another server. I dont want to make RPC calls to the same server serving GWT application and access the required file on server side (like a proxy). I want to access the file directly from client side as my application is going to be hosted as static files in a web server.
Is there a way to do that?
Sure - you must issue a XHR (XmlHTTPRequest) from the browser, and then parse the data.
In GWT you can do it using the RequestBuilder class (see here).
Please note that some client side restrictions may apply (e.g. Single Origin Policy etc.)
You issue the request (GET or POST - GET in your case) and pass a callback instance.
The instance's onResponseReceived method receives a Response object, which by calling its getText method returns the received contents.
You're trying to have your website (a.com/index.html) reference b.com/sample.xml. I see a few options.
If you have access to b.com's servers:
Edit sample.xml into sample.js to contain the same information in JSON with a callback, and reference it with a script tag
Compile your website using the cross-site loader (see Controlling Compiler Output), put your index.html at b.com/index.html, put all the rest of your files on a.com. Then all your RPC calls can go to b.com, but this means the user would have to navigate to b.com instead of a.com
If you don't have access to b.com's servers:
- Simply provide a link for people to download sample.xml
- Host a.com on a server with some kind of script support (PHP, Python, Ruby, Java, anything) and put a proxy to b.com/sample.xml
So... I have a business object/manager which is going to generate emails.
These emails will contain links to various content on the website... and therefore needs to understand about MVC routing.. or at least how to generate URLs for the website...
However my business object will not have access to a RequestContext etc and the email generation is not necessarily the result of a web request to a website (I have a dispatcher which runs on a background thread which will be generating the emails)
Any ideas how I can generate my urls without having access to a request - and therefore being unable to use URLHelper...
Thoughts?
In order to get at the UrlHelper outside of the controller, you need to feed it and the routing data the HttpContext. Here's an example:
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
HttpContextBase context = new HttpContextWrapper(HttpContext.Current);
UrlHelper helper = = new UrlHelper(new RequestContext(context, RouteTable.Routes.GetRouteData(context)));
I prefer to define schema and make both routing and business logic aware of it. Means different implementations of the same URL schema.
Some reasons why:
Your routing mechanism could change. For example in feature you can switch to url_rewrite module.
Possible issues with load-balanced installation.
You do not need even to try to use URLHelper in undocumented way.
BTW, you can replace HttpRequest from URLHelper easily. We used to use this for unit-testing. For more information just search for unit testing of the HttpContextBase or look at examples in source code of the MvcContrib. This can help to instantiate URL helper and all related stuff in non hosted environment. But I still do not think that this is a good idea.
In ASP.NET MVC5 (and possibly MVC4 - I'm not sure when it was introduced), you can do this more directly using HttpRequest.RequestContext. Eg:
var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);