Backstory
I have an XML
type document (SSML
, which is used forText-To-Speech
), which will be used to generate audio files when ssh
transferred to a remote server. As such, I will need to include metadata for the ID3
tags that typically are used in audio files (Genre, Title, Composer, Album, etc...).
My approach thus far has been to invent a new tag:
<metadata value="genre">
Froggy
</metadata>
And then parse it using regular expressions:
/* Grab Metadata */
QTerminalTools tt;
QFile file(filePath);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
const QString metadata = file.readAll();
QString genre(metadata);
genre.replace(QRegularExpression("(?s)^.*"
+ QRegularExpression::escape("<metadata value=\"genre\">")
+"\n(.*)?\n"
+ QRegularExpression::escape("</metadata>")
+ ".*$")
, "\\1");
qDebug().noquote() << tt.orange("Genre: " + genre);
}
This really is a very raw approach that I have made up on the fly, so I figure that there are better practices which I am unaware of. As such:
Questions
- Was XML designed to handle custom metadata?
- Is there already a standard tag in XML for custom metadata (
<metadata value="type">value</metadata>
)? - Are XML parsers standardized in case I need to build my own?
- Are there any security issues involved with creating my own tags?
Thanks.