Get neat content from Wiki page. (MediaWiki API) - android

I want to get a content page from Wiki in this format (the picture below) then show it in WebView. It means the content includes text and links.
I tried this but the output seems to be messy.
http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=Albert_Einstein&format=xmlfm

I stumbled across this answer a year later and would like to note that the ?action=render parameter has been depreciated as of this post.
The recommended method is to use the Mediawiki API to parse the wikitext.

You want index.php?action=render; an example. This returns the HTML of the page content with no sidebar/header/footer HTML. You'll have to match and remove infoboxes yourself.
Reference: MediaWiki — Manual:Parameters to index.php.

You can use HTML generated by mediawiki instead of wikicode.
BTW: look at this

Related

How to get json data from wiki api?

Does anyone have any idea how to use
wikipedia Api for getting some basic json data base on search keyword like:
the Title , some short content or summary ,page url and the most important thing is the image.
I tried to use wiki api sandbox but i can't understand how to use it and set it like i want.
https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&list=search&format=json&srsearch=dog&srnamespace=4&srprop=snippet&srlimit=15&generator=allimages
Any idea?
It's very simple, Here is a test example:
https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=donald%20Trump&format=json
read the docs
https://en.wikipedia.org/w/api.php
https://www.mediawiki.org/wiki/API%3aProperties#revisions_.2F_rv

Can we use a EditText for creating hyperlinks?

We can use a TextViewfor adding hyperlinks to it by various methods, like using the attribute autoLink, or by using setMovementMethod().
Can we do the same using and EditText widget? I am trying to create a notepad, in which if any such text entered, like url, email, number or something similar, we should get a hyperlink to click on it and open the browser.
Please help.
Thanks All.
As of Android API level 8 there is a WEB_URL pattern. Quoting the source, it "match[es] most part of RFC 3987". If you target a lower API level you could simply copy the pattern from the source and include it in your application. I assume you know how to use patterns and matchers, so I'm not going into more details here.
Also the class URLUtil provides some useful methods, e.g:
isHttpUrl()
isValidUrl()
The descriptions of the methods are not very elaborate, therefore you are probably best of looking at the source and figuring out which one fits your purpose best.
As for when to trigger the validation check, there are multiple possibilities: you could use the EditText callback functions
onFocusChanged(), or
onTextChanged()
or use a TextWatcher, which I think would be better.
I hope this helps, best regards,

How to use an XML data from an URL link?

The title maybe a little confusing so I shall explain a lot more details here. First off, I have an URL link that uses HTTPS secured site. I already managed a successful attempt to use a WebView to connect to the site, using loadDataWithBaseURL method.
The URL link does not end with .xml, so I am stuck with this problem. What are the procedures to do in order I can use the xml data on an URL link that does not ends with .xml?
EDIT:
<MGMT>
<NET>
<HEAD>
<ClientID>99999999</ClientID>
<ServerID>WEB_01</ServerID>
<Rsp>00</Rsp>
<Auth></Auth>
</HEAD>
<STAT>
<IP>192.168.5.158</IP>
<Status>OK, Success!</Status>
</NET>
</MGMT>
I do have XML parsing knowledge. But that is if the url link returns a XML data or I have an XML file. This is NOT THE ACTUAL LINK but it is similar, I changed a few values in it.
https://192.168.0.254/?ClientID=999999&Cert=0f7a248e3b017effec2b36cf53912b0f&IP=192.168.5.128
Ok. As i come to know about your question, you have to gain some knowledge about xml parsing which convert the fetched XML data in to specific variables.
Here in below examples, the project get the Http responce from the server which is in the formate of the xml file. (Which URL not having .XML extention). And that data are stored in to specific variable.
You have to fetch various data based on the tab as per your xml structure. as like "MGMT", "NET" . . .etc etc. . .
See this: Example 1
Also see this: Exapmple 2
Hope you got the Logic to do it.

What is the equivalent of Android's Html.fromHtml() in WP7?

Is there a quick and dirty way to render HTML in a textblock in a fashion similar to Android's Html.fromHtml()? I am aware of how to manually parse it with something like the HtmlAgilityPack, but all I really want is for it to render like its source in the textblock.
If not naively then perhaps with a custom control of some sort and, no I don't want to render it as a web page.
Ok sorry it took so long. I all but forgot how to use git correctly and hadn't had the time to upload till now. This HtmlTextBlock offers a similar level of functionality as to that of its silverlight counterpart which is pretty close to the android equivalent. Its still a bit buggy at times when dealing with more complex tags like the html dtd tag but does the job....
WP7 Html Text Block. The design is largely based on this guy's Bringing-a-bit-of-html-to-silverlight-htmltextblock-makes-rich-text-display-easy. and rewriting the web browser related classes using html agility. One day I'll post the details but, blah... Not right now. lol
Update
Example of usage:
<local:HtmlTextBlock x:Name="htmlTextBlock" Canvas.Left="2" Canvas.Top="2" TextWrapping="Wrap" UseDomAsParser="true" Text="&ltp&gtYour Html here &lt/p&gt" />
Note: Your html will have to be escaped such that &lt = < and &gt = >
For detailed usage see:
https://github.com/musicm122/WP7HtmlTextBlock-/blob/master/HtmlTextBlockTest/HtmlTextBlockTest/MainPage.xaml

how to get html source code in android?

What would the best approach to :
get html codes by calling url and displaying it in some views
if i would be editing the values against title tag, it must be automatically updated in the url link?
How to do this?
Check out the JSoup cookbook.
http://jsoup.org/cookbook/
This has a lot of good information in it and should be able to answer most of your questions.
You are probably looking for something along the lines of this: http://jsoup.org/cookbook/input/parse-body-fragment

Categories

Resources