Dear Unified Automation Support,
I have a use case where I need to use an OPC UA method to return a large amount of data in XML format. I have discovered that if I build the XML using UaXmlDocument & related APIs and then return a string with xmlDocument.dumpXmlFile then the string gets padded with extra spaces and newline characters. I expect this was done to improve readability of the XML output, but I don't really want to inflate the size of what gets sent on the wire. Is there a way to switch off the extra padding?
Thanks
UaXmlDocument - output XML is padded with spaces and \n's
Moderator: uasdkcpp
-
- Jr. Member
- Posts: 3
- Joined: 31 Oct 2017, 12:59
- Support Team
- Hero Member
- Posts: 3071
- Joined: 18 Mar 2011, 15:09
Re: UaXmlDocument - output XML is padded with spaces and \n'
Hello Yorwick,
the method UaXmlDocument::dumpXmlFile doesn't take any parameter that allows to change the format.
You can just strip the string manually:
Note that this code may impact performance.
the method UaXmlDocument::dumpXmlFile doesn't take any parameter that allows to change the format.
You can just strip the string manually:
Code: Select all
UaXmlDocument xmlDoc;
...
result = xmlDoc.dumpXmlFile(&szContent, size);
if (result == 0)
{
UaUniString uniStrTmp(szContent);
// remove all whitespaces
uniStrTmp = uniStrTmp.replace(" ", "");
// remove all newlines
uniStrTmp = uniStrTmp.replace("\n", "");
}
Best regards
Unified Automation Support Team
Unified Automation Support Team