VICKY-TSC
VICKY-TSC

Reputation: 415

How to Convert an HTML String to XML DOM

I am using HTTP client 4.1.2.I want to access outlook web and get mails data.Here is the code which I have done.

CredentialsProvider credsProvider = new BasicCredentialsProvider();
    credsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST,         
            AuthScope.ANY_PORT,AuthScope.ANY_REALM, AuthPolicy.BASIC),
    new UsernamePasswordCredentials(Username, password));
DefaultHttpClient Client= new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();

 HttpGet get= new HttpGet(uri);
 HttpEntity entity = response.getEntity();

String html=null;   
if(!entity.equals(null)){
html=EntityUtils.toString(entity,HTTP.UTF_8);
}

The output is HTML page in the from of String.How can I convert this into XML?

Upvotes: 0

Views: 767

Answers (1)

MadProgrammer
MadProgrammer

Reputation: 347184

Technically speaking, well formed HTML is a form of XML, or at least that's the goal any way.

But we're talking Microsoft here...

I use Cobra to interact with HTML as if it was XML, allowing me to use things like xPath to search the document or just access the plain old DOM.

Upvotes: 1

Related Questions