Function 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
);

Returns

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

See Also

getXMLnamespaceFromFile

Example

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);