Comments on: Undocumented XML functionality https://undocumentedmatlab.com/blog_old/undocumented-xml-functionality Charting Matlab's unsupported hidden underbelly Thu, 02 May 2024 08:00:01 +0000 hourly 1 https://wordpress.org/?v=4.4.1 By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/undocumented-xml-functionality#comment-73071 Thu, 02 Feb 2012 00:47:54 +0000 https://undocumentedmatlab.com/?p=751#comment-73071 @James – I don’t have an immediate answer for you, it requires some investigation. This sounds like a good idea for a future article. If you cannot wait for this article to appear, you could contact me by email (link at the top right of this page) to discuss a short consulting gig.

]]>
By: James Myatthttps://undocumentedmatlab.com/blog_old/undocumented-xml-functionality#comment-73029 Wed, 01 Feb 2012 12:10:10 +0000 https://undocumentedmatlab.com/?p=751#comment-73029 @Yair, That certainly sounds like a better idea, but I’m not sure how to proceed. Could you indicate how to modify the parseXML function from the xmlread help so that it used the SAX parser rather than the DOM returned by xmlread? Or am I on the wrong track?

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/undocumented-xml-functionality#comment-72787 Mon, 30 Jan 2012 22:42:18 +0000 https://undocumentedmatlab.com/?p=751#comment-72787 @James – DOM is normally used for small XML models; SAX is usually better for large models that can be processed sequentially. There are numerous SAX parsers available online that you can use in Matlab. Perhaps the most widely used open-source XML parser, which includes support fro both SAX and DOM, is Xerces, which is already pre-bundled in Matlab (take a look at the %matlabroot%/java/jarext/ folder), so you can use it in Matlab out-of-the-box. Other well-known XML support packages, namely Xalan and Saxon, are also pre-bundled.

]]>
By: James Myatthttps://undocumentedmatlab.com/blog_old/undocumented-xml-functionality#comment-72783 Mon, 30 Jan 2012 21:46:58 +0000 https://undocumentedmatlab.com/?p=751#comment-72783 xmlread does a great job of parsing an XML file, but I’ve found that actually extracting data from the DOM hierarchy is pretty slow. For example, the parseXML function in the xmlread help takes about 250 times longer than the call to xmlread itself and vast majority of that time is spent interrogating the DOM objects.

Do you have any suggestions?

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/undocumented-xml-functionality#comment-4530 Sat, 21 Nov 2009 16:36:23 +0000 https://undocumentedmatlab.com/?p=751#comment-4530 Here’s a nicer “pretty-print”, which uses the undocumented InputSource input argument format of xlswrite:

fReader=java.io.FileReader(java.io.File(which('info.xml')));
xmlwrite(org.xml.sax.InputSource(fReader))
]]>
By: Donn Shullhttps://undocumentedmatlab.com/blog_old/undocumented-xml-functionality#comment-4491 Fri, 20 Nov 2009 17:58:22 +0000 https://undocumentedmatlab.com/?p=751#comment-4491 Hi Yair,

It seems that many people follow an unusal convention for the format of their xml files. Even The MathWork’s info.xml files don’t following the standard indented form for xml files. A quick way to “pretty print” an xml file is to use saveXML method of the DOM node ie:

x = xmlread(which('info.xml'));
x.saveXML(x.getDocumentElement)

Thanks for the good work,

Donn

]]>