Read XML in octave

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Read XML in octave

ngdias
This post was updated on .
I'm new in Octave and I'm trying to read XML files.
I read this post
http://octave.1599824.n4.nabble.com/xml-in-octave-td4663034.html

and this section
http://wiki.octave.org/Cookbook#Load_XML_files

I downloaded the .jars from apache and loaded them with javaaddpath.
I can get a result '1' for the code in this last page.

But this function xmlread() https://octave.sourceforge.io/io/function/xmlread.html
is not working:
>> xmlread ();

warning: the 'xmlread' function is not yet implemented in Octave

And the instructions saying run javaaddpath for the 2 .jars doesn't do anything to make xmlread() work.
I'd like to have the xml processing capability load everytime I load Octave and I couldn't find a way to do it. It seems I have to run the javaaddpath command for the 2 .jars everytime I start octave.

Is it supposed to be installed with pkg install -forge and point to the compressed file where I got the .jars from?

All of this is absent from guide pages...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rad XML in octave

siko1056
ngdias wrote
But this function xmlread() https://octave.sourceforge.io/io/function/xmlread.html
is not working:
>> xmlread ();

warning: the 'xmlread' function is not yet implemented in Octave
Did you try to load the "io" package prior to use it?

>> pkg load io

HTH, Kai
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rad XML in octave

tmacchant
In reply to this post by ngdias
----- Original Message -----

> From: ngdias 
> To: help-octave
> Cc:
> Date: 2017/3/22, Wed 05:48
> Subject: Rad XML in octave
>
> I'm new in Octave and I'm trying to read XML files.
> I read this post
> http://octave.1599824.n4.nabble.com/xml-in-octave-td4663034.html
>
> and this section
> http://wiki.octave.org/Cookbook#Load_XML_files
>
> I downloaded the .jars from apache and loaded them with javaaddpath.
> I can get a result '1' for the code in this last page.
>
> But this function xmlread()
> https://octave.sourceforge.io/io/function/xmlread.html
> is not working:
>>>  xmlread ();
>
> warning: the 'xmlread' function is not yet implemented in Octave
>
> And the instructions saying run javaaddpath for the 2 .jars doesn't do
> anything to make xmlread() work.
> I'd like to have the xml processing capability load everytime I load Octave
> and I couldn't find a way to do it. It seems I have to run the javaaddpath
> command for the 2 .jars everytime I start octave.
>
> Is it supposed to be installed with pkg install -forge and point to the
> compressed file where I got the .jars from?
>
> All of this is absent from guide pages...

*******************************

Hello ngdias

I'm not specialist for for xml nor java.
Therefore my suggestion may not be correct.

> http://wiki.octave.org/Cookbook#Load_XML_files


This page seems not to show the way to use xmlread but
load xmlfile without xmlread.

> https://octave.sourceforge.io/io/function/xmlread.html

From the page xmlread is a function of io package of octave-forge 
but is not octave core one.

To use io package, 

1. install io package
From octave prompt

pkg install -forge io

This is required once.
To confirm io package is installed, execute

pkg list io

2. load io package. 
From octave prompt

pkg load io

This is required for  every time before you want use the package.

If you want to load io package at octave startup,
you can use startup file.

https://www.gnu.org/software/octave/doc/interpreter/Startup-Files.html#Startup-Files


Usually I use 
~/.octaverc


If you are a unix like os user, you know what ~ means.
~ indicates home directory.
On windows, home directory is C:\Users\<user name>.

Use an editor and make  .octaverc file in home directory and describe


javaaddpath ("/path/to/xerces-2_11_0/xercesImpl.jar");
javaaddpath ("/path/to/xerces-2_11_0/xml-apis.jar");
pkg load io;

and save it.

Tatsuro

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rad XML in octave

ngdias
This post was updated on .
Thanks so much for all the replies. You have been very helpful, the post by tmacchant was particularly detailed.

I use Windows and Linux, but I'm running Octave in Windows at the moment. The system doesn't allow for the creation of a .octaverc using Explorer (a file needs a filename :P), but I found a workaround by going into the comand line and typing

ren octaverc .octaverc

I think this info about the pkg load io; command is super important and should be mentioned in https://octave.sourceforge.io/io/function/xmlread.html
and
http://wiki.octave.org/Cookbook#Load_XML_files

I don't understand how the javaaddpath commands are mentioned, but not the need to load this package.

Also, could I load Xerces-J-bin.2.11.0.zip as a package instead of
javaaddpath ("/path/to/xerces-2_11_0/xercesImpl.jar");
javaaddpath ("/path/to/xerces-2_11_0/xml-apis.jar");

ie pkg install -forge Xerces-J-bin.2.11.0 ?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rad XML in octave

NJank
On Mar 21, 2017 8:50 PM, "ngdias" <[hidden email]> wrote:
 
Also, could I load Xerces-J-bin.2.11.0.zip as a package instead of
javaaddpath ("/path/to/xerces-2_11_0/xercesImpl.jar");
javaaddpath ("/path/to/xerces-2_11_0/xml-apis.jar");

ie pkg install -forge Xerces-J-bin.2.11.0 ?

I suspect that would not work. The pkg command is specifically made to install prepared Octave packages. I recommend

help pkg

to see how it is used. There you will see the -forge option is only to get and install packages automatically  from the octave forge repository. You can type 

pkg list

to see what you already have installed. If you're on windows and the list is almost empty, you may want to type.:

pkg rebuild

Once to refresh the list

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rad XML in octave

tmacchant
In reply to this post by ngdias
----- Original Message -----

> From: ngdias 
> To: help-octave
> Cc:
> Date: 2017/3/22, Wed 09:42
> Subject: Re: Rad XML in octave
>
>T hanks so much for all the replies. You have been very helpful, the post by
> tmacchant was particularly detailed.
>
> I use Windows and Linux, but I'm running Octave in Windows at the moment.
> The system doesn't allow for the creation of a .octaverc using Explorer (a
> file needs a filename :P), but I found a workaround by going into the comand
> line and typing
>
> ren octaverc .octaverc
>
> I think this info about the pkg load io; command is super important and
> should be mentioned in
> https://octave.sourceforge.io/io/function/xmlread.html
> and
> http://wiki.octave.org/Cookbook#Load_XML_files
>
> I don't understand how the javaaddpath commands are indicated, but not the
> need to load this package.
>
> Also, could I load Xerces-J-bin.2.11.0.zip as a package instead of
> javaaddpath ("/path/to/xerces-2_11_0/xercesImpl.jar");
> javaaddpath ("/path/to/xerces-2_11_0/xml-apis.jar");
>
> ie pkg install -forge Xerces-J-bin.2.11.0 ?


> ie pkg install -forge Xerces-J-bin.2.11.0 ?


It is not.

According to https://octave.sourceforge.io/io/function/xmlread.htm,
Octave does not ship with a Xerces library.


You seems to have to set by yourself.

Extract 
Xerces-J-bin.2.11.0.zip


to the path appropriate for you. 
If you extracted to C:\octave, javaaddpath is to be

javaaddpath ("C:/octave/xerces-2_11_0/xercesImpl.jar"); 

javaaddpath ("C:/octave/xerces-2_11_0/xml-apis.jar"); 


I execute

javaaddpath ("C:/octave/xerces-2_11_0/xercesImpl.jar"); 

javaaddpath ("C:/octave/xerces-2_11_0/xml-apis.jar"); 

pkg load io

And execute Demonstration 1 in  https://octave.sourceforge.io/io/function/xmlread.htm,

But I change graphics_toolkit fltk to qt because fltk causes error.
## Create an svg file, which is nothing but an xml tree tk = graphics_toolkit (); graphics_toolkit ("qt"); % change from fltk to qt hf = figure (); sombrero (); fname = [tempname(), ".svg"]; print (fname); close (hf) graphics_toolkit (tk); ## Read the svg file and check the root node is named "svg" dom = xmlread (fname); if (dom.hasChildNodes ()) root_node = dom.getChildNodes ().item (0); printf ("The name of the root node is \"%s\"\n", ... char (root_node.getNodeName ())) endif
I could see
The name of the root node is "svg"


as shown in Demonstration 1 on the we page.

Tatsuro

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rad XML in octave

tmacchant


> And execute Demonstration 1 in
>  https://octave.sourceforge.io/io/function/xmlread.htm,


 
> But I change graphics_toolkit fltk to qt because fltk causes error.
> ## Create an svg file, which is nothing but an xml tree tk = graphics_toolkit
> (); graphics_toolkit ("qt"); % change from fltk to qt hf = figure ();
> sombrero (); fname = [tempname(), ".svg"]; print (fname); close (hf)
> graphics_toolkit (tk); ## Read the svg file and check the root node is named
> "svg" dom = xmlread (fname); if (dom.hasChildNodes ()) root_node =
> dom.getChildNodes ().item (0); printf ("The name of the root node is
> \"%s\"\n", ... char (root_node.getNodeName ())) endif


Sorry I copied and pasted from web site to my yahoo mail but line feed seems to be erased.

For octave-4.2.1, fltk does not work for  me.
I used gt graphics_toolkit instead.


> I could see
> The name of the root node is "svg"
>
>
> as shown in Demonstration 1 on the we page.
>
> Tatsuro
>

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rad XML in octave

ngdias
This post was updated on .
tmacchant wrote
> But I change graphics_toolkit fltk to qt because fltk causes error.
Yes, I also got a program hang when trying to run that demo.
One has to change the graphics toolkit everytime some code is executed, or is there a way to set it as part of the environment when Octave is started?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rad XML in octave

tmacchant
In reply to this post by tmacchant
--- ngdias
> tmacchant wrote
> >> But I change graphics_toolkit fltk to qt because fltk causes error.
>
> Yes, I also got a program hang when trying to run that demo. How does one
> change the graphics toolkit?
>
>
>
>
Change the line in the demo code

graphics_toolkit ("fltk");

to

graphics_toolkit ("qt");

Tatsuro

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Loading...