getXMLnamespaceFromData

Get XML namespace from text data. The text is not required to be a data of the whole file. Note however that some xml files may contain a big portion of DOCTYPE declaration at the start.

string
getXMLnamespaceFromData
(
const(char)[] xmlData
)

Return Value

Type: string

xmlns attribute of the root xml element or null if text is not xml-formatted or does not have a namespace.

Examples

auto xmlData = `<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">`;
assert(getXMLnamespaceFromData(xmlData) == "http://www.freedesktop.org/standards/shared-mime-info");
assert(getXMLnamespaceFromData("<start-element>") == string.init);
assert(getXMLnamespaceFromData("") == string.init);

See Also

Meta