[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: XML tools for Octave
From: |
Schloegl Alois |
Subject: |
Re: XML tools for Octave |
Date: |
Fri, 09 Jun 2006 11:52:15 +0200 |
User-agent: |
Internet Messaging Program (IMP) H3 (4.2-cvs) |
Quoting David Bateman <address@hidden>:
As a fairly dumb conversion of xmldata to an oct-file (though I tried to
replace C strings with the C++ std::string class), how does the attached
work. Basically, I've just tested to the point where is compiles and no
further. I also think there is a serious problem in the original code in
that malformed input might cause a seg-fault. Consider the example
"</xml>v</xml>" that seems to me will not create the struct to contain
the field and then try to assign to it. I tried to fix this.
The conversion is very direct and there are ugly multiple assignments to
the return value list. It would be better to get rid of these. Help
strings etc might also be improved..
D.
When I tried to apply it to a large XML file, it reads only the first
elements.
octave:27>
fid=fopen('Exa01.xml');s=char(fread(fid,[1,inf],'char'));fclose(fid)
ans = 0
octave:28> list= xmlstruct(char(s))octave:2
list =
{
data =
(,
[1] =
{
encoding = utf-8
version = 1.0
x_ = 1.0
}
[2] =
,)
name =
(,
[1] = x_xml
[2] = <!-- Sample Annotated ECG -->
,)
type =
(,
[1] = 1
[2] = 0
,)
}
octave:29> struct= xmlstruct(char(s),'sub')
struct =
{
data =
{
encoding = utf-8
version = 1.0
x_ = 1.0
}
name = x_xml
sub =
{
data =
name = <!-- Sample Annotated ECG -->
type = 0
}
type = 1
}
The original version returns on the same file 2430 elements.
fid=fopen('Exa01.xml');s=char(fread(fid,[1,inf],'char'));fclose(fid);
list= xmlstruct(char(s))
list =
1x2430 struct array with fields:
name
data
type
t= xmlstruct(char(s),'sub')
t =
name: 'x_xml'
data: [1x1 struct]
type: 1
sub: [1x10 struct]
A.
- Re: XML tools for Octave, Alois Schloegl, 2006/06/08
- Re: XML tools for Octave, David Bateman, 2006/06/08
- Re: XML tools for Octave, Alois Schloegl, 2006/06/08
- Re: XML tools for Octave, David Bateman, 2006/06/08
- Re: XML tools for Octave,
Schloegl Alois <=
- Re: XML tools for Octave, David Bateman, 2006/06/09
- Re: XML tools for Octave, David Bateman, 2006/06/09
- Re: XML tools for Octave, Schloegl Alois, 2006/06/10
- Re: XML tools for Octave, David Bateman, 2006/06/10
- Re: XML tools for Octave, Andy Adler, 2006/06/10
- Re: XML tools for Octave, Alois Schloegl, 2006/06/12
- Re: XML tools for Octave, Andy Adler, 2006/06/12
- Re: XML tools for Octave, Alois Schloegl, 2006/06/13
- Re: XML tools for Octave, Andy Adler, 2006/06/13
- Re: XML tools for Octave, Schloegl Alois, 2006/06/21