4
edits
Line 123: | Line 123: | ||
Reading XML in octave can be achieved using the java library [http://xerces.apache.org/ Xerces] (from apache). | Reading XML in octave can be achieved using the java library [http://xerces.apache.org/ Xerces] (from apache). | ||
It seems that the matlab's xmlread is just a thin wrapper around the Xerces library | It seems that the matlab's xmlread is just a thin wrapper around the Xerces library. One should note however, that Java functions have the working directory set to the working directory when octave starts and the working directory is not modified by a cd in octave. Matlab has the same behavior, as Java does not provide a way to change the current working directory (http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4045688). To avoid any issues, it is thus better to use the absolute path to the XML file. | ||
You need the jar | You need the jar files xercesImpl.jar and xml-apis.jar from e.g. https://www.apache.org/dist/xerces/j/Xerces-J-bin.2.11.0.tar.gz (check for the latest version). | ||
Use javaaddpath to include these files: | Use javaaddpath to include these files: | ||
{{Code| | {{Code|Define java path|<syntaxhighlight lang="octave" style="font-size:1.1em"> | ||
javaaddpath('/path/to/xerces-2_11_0/xercesImpl.jar'); | javaaddpath('/path/to/xerces-2_11_0/xercesImpl.jar'); | ||
javaaddpath('/path/to/xerces-2_11_0/xml-apis.jar'); | javaaddpath('/path/to/xerces-2_11_0/xml-apis.jar'); | ||
Line 135: | Line 135: | ||
A sample script: | A sample script: | ||
{{Code|Load | {{Code|Load XML file|<syntaxhighlight lang="octave" style="font-size:1.1em"> | ||
filename = 'sample.xml'; | filename = 'sample.xml'; | ||
Line 153: | Line 153: | ||
The file <tt>sample.xml</tt>: | The file <tt>sample.xml</tt>: | ||
{{Code|Sample XML file|<syntaxhighlight lang="xml" style="font-size:1.1em"> | |||
<root> | <root> | ||
<data att="1">hello</data> | <data att="1">hello</data> | ||
</root> | </root> | ||
</syntaxhighlight>}} | |||
===Using variable strings in commands=== | ===Using variable strings in commands=== |
edits