c# - Reading specific content from a web page? -
i trying make app (in c#) in have meanings website wiktionary.com or dictionary.com. have never used xml or worked web pages @ all.
i managed response webpage (e.g dictionary.com specific word) (which hope xml format).
this got word 'hello'.:
<!doctype html public "-//w3c//dtd html 4.0 strict//en"> <!--attributes answers reference--> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/"> <head> <title> hello | define hello @ dictionary.com </title> <meta name="description" content="hello definition, (used express greeting, answer telephone, or attract attention.) see more."/> <meta name="keywords" content="hello, online dictionary, english dictionary, hello definition, define hello, definition of hello, hello pronunciation, hello meaning, hello origin, hello examples"/> <link rel="canonical" href="http://dictionary.reference.com/browse/hello"/> <meta property="og:title" content="the definition of hello"/> <meta property="og:site_name" content="dictionary.com"/> <meta property="og:image" content="http://sp2.dictionary.com/en/i/dictionary/facebook/dictionary_logo.png"/> now want parse following string out of response.
used express greeting, answer telephone, or attract attention. i tried using xmlreader got stuck. can please me read content?
you can parse html http://htmlagilitypack.codeplex.com/
htmldocument doc = new htmldocument(); // replace own content doc.load("file.htm"); foreach(htmlnode meta in doc.documentelement.selectnodes("/meta[@name='description'"]) { htmlattribute att = meta["content"]; consol.writeline( att.value ); }
Comments
Post a Comment