本文整理汇总了C#中DOM类的典型用法代码示例。如果您正苦于以下问题:C# DOM类的具体用法?C# DOM怎么用?C# DOM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DOM类属于命名空间,在下文中一共展示了DOM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetByQuery
public Player GetByQuery(string name)
{
var SearchResultUrl = "http://svenskfotboll.se/sok/?q=" + name + "&search-type=0";
var SearchDOM = new DOM(SearchResultUrl);
if (SearchDOM != null)
{
var PlayerUrls = Regex.Match(SearchDOM.Html, "<a href=\"(http://svenskfotboll.se/.*/person/.playerid=\\d*)\"");
if (PlayerUrls.Success)
{
string PlayerProfileUrl = PlayerUrls.Groups[1].Value;
return GetPlayerProfile(PlayerProfileUrl);
}
}
else
{
return null;
}
return null;
}
示例2: GetPlayerProfile
private Player GetPlayerProfile(string url)
{
var Document = new DOM(url);
Player player = new Player();
player.Id = Regex.Match(url, "playerid=(\\d*)").Groups[1].Value;
player.Permalink = url;
player.Name = Document.DocumentModel.SelectSingleNode("//h1[@class='h']").InnerText;
player.ImageUrl = "http://svenskfotboll.se" + Document.DocumentModel.SelectSingleNode("//div[@class='player-image']/img/@src").InnerText;
var TableRows = Document.DocumentModel.SelectNodes("//table[@class='clTblStatBox']//tr");
player.ShirtNumber = Document.DocumentModel.SelectSingleNode("//table[@class='clTblStatBox']//thead").InnerText;
player.ShirtNumber = Regex.Match(player.ShirtNumber, "Nr (\\d*)").Groups[1].Value;
player.BirthDate = TableRows.GetCellValueByFirstColumn("Född:");
var HeightAndWeight = TableRows.GetCellValueByFirstColumn("Längd/Vikt:");
if (HeightAndWeight.Contains("/"))
{
player.Height = HeightAndWeight.Split('/')[0];
player.Weight = HeightAndWeight.Split('/')[1];
}
player.MotherClub = TableRows.GetCellValueByFirstColumn("Moderklubb:");
return player;
}
示例3: ParseMatches
public List<Match> ParseMatches(DOM document)
{
var matches = new List<Match>();
try
{
var upcomingGamesSection = document.HtmlDoc.DocumentNode.SelectSingleNode("//section[@class='upcoming-games']");
var matchRows = upcomingGamesSection.SelectNodes("//tr[@data-match-id]");
var homeTeamNodes = upcomingGamesSection.SelectNodes("//span[@class='team home']");
var awayTeamNodes = upcomingGamesSection.SelectNodes("//span[@class='team away']");
var matchDates = upcomingGamesSection.SelectNodes("//span[@class='date-short matchTid']");
var matchTimes = upcomingGamesSection.SelectNodes("//span[@class='time matchTid']");
var locations = upcomingGamesSection.SelectNodes("//a[@class='location']");
for (int i = 0; i < matchRows.Count; i++)
{
var homeTeamNode = homeTeamNodes[i];
var homeTeamName = HttpUtility.HtmlDecode(homeTeamNode.InnerHtml);
var awayTeamNode = awayTeamNodes[i];
var awayTeamName = HttpUtility.HtmlDecode(awayTeamNode.InnerHtml);
var matchDate = matchDates[i].InnerText;
if (matchDate == "Imorgon")
{
var tomorrow = DateTime.Now.AddDays(1);
matchDate = string.Format("{0}/{1}", tomorrow.Day, tomorrow.Month);
}
if (matchDate == "Idag")
{
var today = DateTime.Now;
matchDate = string.Format("{0}/{1}", today.Day, today.Month);
}
var dateParts = matchDate.Split("/".ToCharArray());
var dayOfMonth = int.Parse(dateParts[0]);
var month = int.Parse(dateParts[1]);
var matchTime = matchTimes[i].InnerText;
var timeParts = matchTime.Split(":".ToCharArray());
var hour = int.Parse(timeParts[0]);
var minutes = int.Parse(timeParts[1]);
var matchDateComplete = new DateTime(DateTime.Now.Year, month, dayOfMonth, hour, minutes, 0);
var location = locations[i].InnerText;
matches.Add(Match.CreateNew(matchDateComplete, homeTeamName, awayTeamName, location));
}
return matches;
}
catch (Exception)
{
return matches;
}
}
示例4: GetUpcomingMatches
public List<Match> GetUpcomingMatches(int seriesID)
{
List<Match> Upcoming = (List<Match>)Utilities.GetFromCache(seriesID + ":Upcoming");
if (Upcoming == null)
{
Upcoming = new List<Match>();
DOM Document = new DOM(GetWidgetUrl("cominginleague", seriesID));
var TableRows = Document.Query("tr");
char[] querystringSplitChar = { '=' };
int RowCount = 0;
foreach (XmlNode Row in TableRows)
{
try
{
if (RowCount > 2)
{
var Columns = Row.SelectNodes("td");
Match match = new Match();
match.Time = DateTime.Parse(Columns.ValueOfIndex(0));
match.MatchName = Columns.ValueOfIndex(1);
string MatchURI = Columns[1].SelectSingleNode("a").GetAttributeValue("href");
match.ID = MatchURI.Split(querystringSplitChar).LastOrDefault().ToString();
PopulateMatchDetails(match);
Upcoming.Add(match);
}
RowCount = RowCount + 1;
}
catch (Exception ex)
{
}
}
Utilities.InsertToCache(seriesID + ":Upcoming", Upcoming);
}
return Upcoming;
}
示例5: GetScoreTable
public List<TeamResults> GetScoreTable(int seriesID)
{
List<TeamResults> ScoreTable = (List<TeamResults>)Utilities.GetFromCache(seriesID + ":Scores");
if (ScoreTable == null)
{
ScoreTable = new List<TeamResults>();
DOM Document = new DOM(GetWidgetUrl("table", seriesID));
var TableRows = Document.Query("table//tr");
int RowCount = 0;
foreach (XmlNode Row in TableRows)
{
if (RowCount > 2)
{
var Columns = Row.SelectNodes("td");
TeamResults score = new TeamResults();
score.TeamName = Columns.ValueOfIndex(0);
score.MatchesPlayed = Columns.ValueOfIndex(1);
score.MatchesWon = Columns.ValueOfIndex(2);
score.MatchesDraw = Columns.ValueOfIndex(3);
score.MatchesLost = Columns.ValueOfIndex(4);
score.GoalsMadeAndReceived = Columns.ValueOfIndex(5);
score.Difference = Columns.ValueOfIndex(6);
score.Points = Columns.ValueOfIndex(7);
ScoreTable.Add(score);
}
RowCount = RowCount + 1;
}
Utilities.InsertToCache(seriesID + ":Scores", ScoreTable);
}
return ScoreTable;
}
示例6: GetSeries
public List<Series> GetSeries()
{
List<Series> AllSeries = (List<Series>)Utilities.GetFromCache("AllSeries");
if (AllSeries == null) {
AllSeries = new List<Series>();
DOM Document = new DOM("http://www.svenskfotboll.se");
var Series = Document.Query("select[@id='ftid-stickybar']//option");
foreach(XmlNode node in Series){
Series serie = new Series();
serie.ID = int.Parse(node.GetAttributeValue("value"));
serie.Name = node.InnerText;
AllSeries.Add(serie);
}
Utilities.InsertToCache("AllSeries", AllSeries);
}
return AllSeries;
}
示例7: KhtmlValidAttrName
public static bool KhtmlValidAttrName(DOM.DOMString name)
{
return (bool) staticInterceptor.Invoke("khtmlValidAttrName#", "khtmlValidAttrName(const DOM::DOMString&)", typeof(bool), typeof(DOM.DOMString), name);
}
示例8: AcceptNode
public virtual short AcceptNode(DOM.Node n)
{
return (short) interceptor.Invoke("acceptNode#", "acceptNode(const DOM::Node&)", typeof(short), typeof(DOM.Node), n);
}
示例9: HTMLTableElement
public HTMLTableElement(DOM.HTMLTableElement other)
: this((Type) null)
{
CreateProxy();
interceptor.Invoke("HTMLTableElement#", "HTMLTableElement(const DOM::HTMLTableElement&)", typeof(void), typeof(DOM.HTMLTableElement), other);
}
示例10: SetTHead
/// <remarks>
/// see tHead
/// </remarks> <short> see tHead </short>
public void SetTHead(DOM.HTMLTableSectionElement arg1)
{
interceptor.Invoke("setTHead#", "setTHead(const DOM::HTMLTableSectionElement&)", typeof(void), typeof(DOM.HTMLTableSectionElement), arg1);
}
示例11: HTMLSelectElement
public HTMLSelectElement(DOM.Node other)
: this((Type) null)
{
CreateProxy();
interceptor.Invoke("HTMLSelectElement#", "HTMLSelectElement(const DOM::Node&)", typeof(void), typeof(DOM.Node), other);
}
示例12: DOMImplementation
public DOMImplementation(DOM.DOMImplementation other)
: this((Type) null)
{
CreateProxy();
interceptor.Invoke("DOMImplementation#", "DOMImplementation(const DOM::DOMImplementation&)", typeof(void), typeof(DOM.DOMImplementation), other);
}
示例13: DocumentFragment
public DocumentFragment(DOM.Node other)
: this((Type) null)
{
CreateProxy();
interceptor.Invoke("DocumentFragment#", "DocumentFragment(const DOM::Node&)", typeof(void), typeof(DOM.Node), other);
}
示例14: AbstractView
public AbstractView(DOM.AbstractView other)
: this((Type) null)
{
CreateProxy();
interceptor.Invoke("AbstractView#", "AbstractView(const DOM::AbstractView&)", typeof(void), typeof(DOM.AbstractView), other);
}
示例15: GetInterface
/// <remarks>
/// Introduced in DOM Level 3
/// This method makes available a DOMImplementation's specialized
/// interface.
/// <param> name="feature" The name of the feature requested (case-insensitive)
/// </param></remarks> <return> Returns an alternate DOMImplementation which implements
/// the specialized APIs of the specified feature, if any, or null
/// if there is no alternate DOMImplementation object which implements
/// interfaces associated with that feature. Any alternate DOMImplementation
/// returned by this method must delegate to the primary core DOMImplementation
/// and not return results inconsistent with the primary DOMImplementation.
/// </return>
/// <short> Introduced in DOM Level 3 This method makes available a DOMImplementation's specialized interface.</short>
public DOM.DOMImplementation GetInterface(DOM.DOMString feature)
{
return (DOM.DOMImplementation) interceptor.Invoke("getInterface#", "getInterface(const DOM::DOMString&) const", typeof(DOM.DOMImplementation), typeof(DOM.DOMString), feature);
}