Element.GetElementsByTagNameNS

Element.GetElementsByTagNameNS method

Returns HTMLCollection object containing all elements with a given local name and package URI String in document order.

public HTMLCollection GetElementsByTagNameNS(String packageURI, String localName)
ParameterTypeDescription
packageURIStringThe package URI String representation.
localNameStringString representation of local name.

Return Value

An HTMLCollection object is an array-like list of elements.

Remarks

Refer to official spec.

You may also be interested in documentation.

You can download the complete examples and data files from GitHub.

Examples

# .xhtml input file content
<!DOCTYPE html>
<html lang="en"
   xmlns="http://www.w3.org/1999/xhtml"
   xmlns:custom="http://www.company.com">
<head>
	<meta charset="UTF-8"/>
	<link rel="stylesheet" href="/styles/main.css"/>
	<title>Title</title>
</head>
<body>
<custom:customtag>
	Custom package custom tag content goes here...
</custom:customtag>
</body>
</html>

# C# code
import System;
import com.aspose.html;
import com.aspose.html.Collections;
import com.aspose.html.Dom;
...
import (var document = new HTMLDocument(inputHtmlPath))
{
	// User code goes here

	HTMLCollection htmlCollection = document.GetElementsByTagNameNS("http://www.company.com", "customtag");
	Console.WriteLine($"Found: {htmlCollection.Length}");
	foreach (Element element in htmlCollection)
	{
		Console.WriteLine(element.InnerHTML);
	}

	// User code goes here
}

*inputHtmlPath - user input xhtml file path.

Console output

Found: 1

Custom package custom tag content goes here…

See Also