Class RdfAParser
Class for reading RDF embedded as RDFa from within HTML web pages.
Implements
Inherited Members
Namespace: VDS.RDF.Parsing
Assembly: dotNetRdf.dll
Syntax
public class RdfAParser : RdfAParserBase<HtmlDocument, HtmlNode, HtmlNode, HtmlAttribute>, IRdfReader
Remarks
The RDFa parser uses a HTML parser (Html Agility Pack) that is highly tolerant of real-world HTML and so is able to extract RDFa from pages that are not strictly valid HTML/XHTML.
Constructors
| Edit this page View SourceRdfAParser()
Creates a new RDFa Parser which will auto-detect which RDFa version to use (assumes 1.1 if none explicitly specified).
Declaration
public RdfAParser()
RdfAParser(RdfAParserOptions)
Creates a new RDFa parser with the provided configuration options.
Declaration
public RdfAParser(RdfAParserOptions parserOptions)
Parameters
Type | Name | Description |
---|---|---|
RdfAParserOptions | parserOptions | The options to use to configure the parser. |
RdfAParser(RdfASyntax)
Creates a new RDFa Parser which will use the specified RDFa syntax.
Declaration
public RdfAParser(RdfASyntax syntax)
Parameters
Type | Name | Description |
---|---|---|
RdfASyntax | syntax | RDFa Syntax Version. |
Methods
| Edit this page View SourceGetAttribute(HtmlNode, string)
Get the value of a particular attribute of an element.
Declaration
protected override string GetAttribute(HtmlNode element, string attributeName)
Parameters
Type | Name | Description |
---|---|---|
HtmlNode | element | The element. |
string | attributeName | The name of the attribute on the element. |
Returns
Type | Description |
---|---|
string | The value of the attribute. |
Overrides
| Edit this page View SourceGetAttributeName(HtmlAttribute)
Get the name of an attribute.
Declaration
protected override string GetAttributeName(HtmlAttribute attribute)
Parameters
Type | Name | Description |
---|---|---|
HtmlAttribute | attribute |
Returns
Type | Description |
---|---|
string |
Overrides
| Edit this page View SourceGetAttributeValue(HtmlAttribute)
Get the value of an attribute.
Declaration
protected override string GetAttributeValue(HtmlAttribute attribute)
Parameters
Type | Name | Description |
---|---|---|
HtmlAttribute | attribute |
Returns
Type | Description |
---|---|
string |
Overrides
| Edit this page View SourceGetAttributes(HtmlNode)
Get all attributes of an element.
Declaration
protected override IEnumerable<HtmlAttribute> GetAttributes(HtmlNode element)
Parameters
Type | Name | Description |
---|---|---|
HtmlNode | element |
Returns
Type | Description |
---|---|
IEnumerable<HtmlAttribute> |
Overrides
| Edit this page View SourceGetBaseElement(HtmlDocument)
Get the base element of the specified document.
Declaration
protected override HtmlNode GetBaseElement(HtmlDocument document)
Parameters
Type | Name | Description |
---|---|---|
HtmlDocument | document |
Returns
Type | Description |
---|---|
HtmlNode |
Overrides
| Edit this page View SourceGetChildren(HtmlNode)
Return the children of an element (in order).
Declaration
protected override IEnumerable<HtmlNode> GetChildren(HtmlNode element)
Parameters
Type | Name | Description |
---|---|---|
HtmlNode | element |
Returns
Type | Description |
---|---|
IEnumerable<HtmlNode> |
Overrides
| Edit this page View SourceGetElementName(HtmlNode)
Get the name of an element.
Declaration
protected override string GetElementName(HtmlNode element)
Parameters
Type | Name | Description |
---|---|---|
HtmlNode | element |
Returns
Type | Description |
---|---|
string |
Overrides
| Edit this page View SourceGetHtmlElement(HtmlDocument)
Get the html element of the document.
Declaration
protected override HtmlNode GetHtmlElement(HtmlDocument document)
Parameters
Type | Name | Description |
---|---|---|
HtmlDocument | document |
Returns
Type | Description |
---|---|
HtmlNode |
Overrides
| Edit this page View SourceGetInnerHtml(HtmlNode)
Get the HTML contained within an element as a string.
Declaration
protected override string GetInnerHtml(HtmlNode element)
Parameters
Type | Name | Description |
---|---|---|
HtmlNode | element |
Returns
Type | Description |
---|---|
string |
Overrides
| Edit this page View SourceGetInnerText(HtmlNode)
Get the inner text of an element or a text node.
Declaration
protected override string GetInnerText(HtmlNode node)
Parameters
Type | Name | Description |
---|---|---|
HtmlNode | node |
Returns
Type | Description |
---|---|
string |
Overrides
| Edit this page View SourceGrabText(StringBuilder, HtmlNode)
Get the text content of a node and add it to the provided output buffer.
Declaration
protected override void GrabText(StringBuilder output, HtmlNode node)
Parameters
Type | Name | Description |
---|---|---|
StringBuilder | output | |
HtmlNode | node |
Overrides
| Edit this page View SourceHasAttribute(HtmlNode, string)
Determine if an element has a particular attribute.
Declaration
protected override bool HasAttribute(HtmlNode element, string attributeName)
Parameters
Type | Name | Description |
---|---|---|
HtmlNode | element | The element to check. |
string | attributeName | The name of the attribute to check for. |
Returns
Type | Description |
---|---|
bool | True if the element has an attribute named |
Overrides
| Edit this page View SourceHasChildren(HtmlNode)
Determine if an element has children.
Declaration
protected override bool HasChildren(HtmlNode element)
Parameters
Type | Name | Description |
---|---|---|
HtmlNode | element |
Returns
Type | Description |
---|---|
bool | True if the element has children, false otherwise. |
Overrides
| Edit this page View SourceIsElement(HtmlNode)
Determine if a node in the parsed HTML document tree is an element node.
Declaration
protected override bool IsElement(HtmlNode node)
Parameters
Type | Name | Description |
---|---|---|
HtmlNode | node | The node to evaluate. |
Returns
Type | Description |
---|---|
bool | True if |
Overrides
| Edit this page View SourceIsRoot(HtmlNode)
Determine if a node in the parsed HTML document tree is the root document node.
Declaration
protected override bool IsRoot(HtmlNode node)
Parameters
Type | Name | Description |
---|---|---|
HtmlNode | node | The node to evaluate. |
Returns
Type | Description |
---|---|
bool | True if |
Overrides
| Edit this page View SourceIsTextNode(HtmlNode)
Determine if a node in the parsed Html document tree is a text node.
Declaration
protected override bool IsTextNode(HtmlNode node)
Parameters
Type | Name | Description |
---|---|---|
HtmlNode | node |
Returns
Type | Description |
---|---|
bool | True if |
Overrides
| Edit this page View SourceIsXmlBaseIsPermissible(HtmlDocument)
Determine if the HTML document can have an xml:base element.
Declaration
protected override bool IsXmlBaseIsPermissible(HtmlDocument document)
Parameters
Type | Name | Description |
---|---|---|
HtmlDocument | document |
Returns
Type | Description |
---|---|
bool |
Overrides
LoadAndParse(TextReader)
Parse the input stream as an HTML document.
Declaration
protected override HtmlDocument LoadAndParse(TextReader input)
Parameters
Type | Name | Description |
---|---|---|
TextReader | input |
Returns
Type | Description |
---|---|
HtmlDocument |
Overrides
| Edit this page View SourceProcessDocument(RdfAParserContext<HtmlDocument>, RdfAEvaluationContext)
Process the content of an HTML document.
Declaration
protected override void ProcessDocument(RdfAParserContext<HtmlDocument> context, RdfAEvaluationContext evalContext)
Parameters
Type | Name | Description |
---|---|---|
RdfAParserContext<HtmlDocument> | context | |
RdfAEvaluationContext | evalContext |
Overrides
| Edit this page View SourceSetAttribute(HtmlNode, string, string)
Set the value of a particular attribute of an element.
Declaration
protected override void SetAttribute(HtmlNode element, string attributeName, string value)
Parameters
Type | Name | Description |
---|---|---|
HtmlNode | element | The element. |
string | attributeName | The name of the attribute to set/update. |
string | value | The new value for the attribute. |