473,486 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

parsing xml with embedded csv

Hi All;
I'm working on a data acquisition system, the system runs on Linux, and the
config files are Xml like.

eg
<CHANNELS>
<META>
Short Label,textbox,width=5,Alpha,required
Long Label,textbox,width=15,Alpha,required
Crate,select,1,2
Channel,textbox,width=5,Numeric,Min=0,Max=9999
ESP flag,checkbox
RMS flag,checkbox
Rate LS,select,1,10,100,1000
Rate HS,select,1,10,100,1000
Cal Factor,textbox,width=7,Numeric
Zero offset,textbox,width=7,Numeric
Exc. Voltage,textbox,width=7,Numeric
Amp Gain,select,1,10,20,50,100,200,500,1000
LP filter,select,1=10Hz,2=100Hz,3=1KHz
RMS gain,select,1,10,20,50,100
PS#,select,1,2,3,4,5
DIN#,special,type=din
</META>
<FIELDNAMES>
Short Label,Long Label,Crate,Channel,ESP flag,RMS flag,Rate LS,Rate HS,Cal
Factor,Zero offset,Exc. Voltage,Amp Gain,LP filter,RMS gain,PS#,DIN#
</FIELDNAMES>
<DATA>
TM,TM,0,142,,,1,,0.00046566,0,1,1,0,1,77,0
--,--,0,143,,,1,,30.5176,0,1,1,0,1,77,0
P0,P0,0,4042,,,1,,30.5176,0,1,1,0,1,77,6204
TP,TP,0,231,,,1,,30,-0.12976,1,1,0,1,77,0
LF,LF,0,224,,,1,,41.666,-10.194,1,1,0,1,77,0
FP,FP,0,226,,,1,,5.0505,-333.97,1,1,0,1,77,0
</DATA>
</CHANNELS>

Using libxml, I've parsed out the fields using the tree1 example, but I
can't figure out how to rewind the stream, so I can start looking for a
different block. I have ~12 programs that need to access different blocks so
I'm thinking I'll make a parser.lib, but I need a way to rewind.
Any ideas?

Jan 13 '06 #1
5 1632
Pat Ford <pa******@nrc.ca> wrote:
Hi All;
I'm working on a data acquisition system, the system runs on Linux, and the
config files are Xml like.

eg
<CHANNELS>
<META>
Short Label,textbox,width=5,Alpha,required
Long Label,textbox,width=15,Alpha,required
Crate,select,1,2
Channel,textbox,width=5,Numeric,Min=0,Max=9999
ESP flag,checkbox
RMS flag,checkbox
Rate LS,select,1,10,100,1000
Rate HS,select,1,10,100,1000
Cal Factor,textbox,width=7,Numeric
Zero offset,textbox,width=7,Numeric
Exc. Voltage,textbox,width=7,Numeric
Amp Gain,select,1,10,20,50,100,200,500,1000
LP filter,select,1=10Hz,2=100Hz,3=1KHz
RMS gain,select,1,10,20,50,100
PS#,select,1,2,3,4,5
DIN#,special,type=din
</META>
<FIELDNAMES>
Short Label,Long Label,Crate,Channel,ESP flag,RMS flag,Rate LS,Rate HS,Cal
Factor,Zero offset,Exc. Voltage,Amp Gain,LP filter,RMS gain,PS#,DIN#
</FIELDNAMES>
<DATA>
TM,TM,0,142,,,1,,0.00046566,0,1,1,0,1,77,0
--,--,0,143,,,1,,30.5176,0,1,1,0,1,77,0
P0,P0,0,4042,,,1,,30.5176,0,1,1,0,1,77,6204
TP,TP,0,231,,,1,,30,-0.12976,1,1,0,1,77,0
LF,LF,0,224,,,1,,41.666,-10.194,1,1,0,1,77,0
FP,FP,0,226,,,1,,5.0505,-333.97,1,1,0,1,77,0
</DATA>
</CHANNELS>

Using libxml, I've parsed out the fields using the tree1 example, but I
can't figure out how to rewind the stream, so I can start looking for a
different block. I have ~12 programs that need to access different blocks so
I'm thinking I'll make a parser.lib, but I need a way to rewind.
Any ideas?


I don't quite get "rewinding". How is it different from just reading
the file again?

--
William Park <op**********@yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
Jan 14 '06 #2
Pat Ford wrote:
Hi All;
I'm working on a data acquisition system, the system runs on Linux, and the
config files are Xml like.

eg
<CHANNELS>
<META>
Short Label,textbox,width=5,Alpha,required
Long Label,textbox,width=15,Alpha,required [...]

Eww. Looks like someone just wrapped the original data in tags and hoped
for the best. <sigh/>
Using libxml, I've parsed out the fields using the tree1 example, but I
can't figure out how to rewind the stream, so I can start looking for a
different block. I have ~12 programs that need to access different blocks so
I'm thinking I'll make a parser.lib, but I need a way to rewind.


The concept doesn't exist in XML processing. If you use a language like
XSLT you can address any location in the document at any time, so you
can write templates which perform the various tests you require.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Jan 15 '06 #3

"Peter Flynn" <pe********@m.silmaril.ie> wrote in message
news:42*************@individual.net...
Pat Ford wrote:
Hi All;
I'm working on a data acquisition system, the system runs on Linux, and the config files are Xml like.

eg
<CHANNELS>
<META>
Short Label,textbox,width=5,Alpha,required
Long Label,textbox,width=15,Alpha,required [...]

Eww. Looks like someone just wrapped the original data in tags and hoped
for the best. <sigh/>


The lusers, opps I mean users have insisted that they keep the interface to
the data system windows based. I don't do windows, so a web based interface
was crafted. We need flexibility, so the meta block defines how the
interface for that block will look, the fieldnames describe what is in each
column ( we can add new fields anywhere in the form as new features creap
in), then the config data is csv. It boils down to legacy users, legacy
format and multiple OS and programming environments.
Using libxml, I've parsed out the fields using the tree1 example, but I
can't figure out how to rewind the stream, so I can start looking for a
different block. I have ~12 programs that need to access different blocks so I'm thinking I'll make a parser.lib, but I need a way to rewind.


The concept doesn't exist in XML processing. If you use a language like
XSLT you can address any location in the document at any time, so you
can write templates which perform the various tests you require.

///Peter
--
XML FAQ: http://xml.silmaril.ie/


I'm hoping to have a function along the lines of;
float getIntField ( char* blockName, char* fieldname, int line)
float getFloatField ( char* blockName, char* fieldname, int line)
char* getStringField ( char* blockName, char* fieldname, int line)
....
I'm pretty much constrained to that ugly file format.
Jan 16 '06 #4

"William Park" <op**********@yahoo.ca> wrote in message
news:b6**************************@PRIMUS.CA...
Pat Ford <pa******@nrc.ca> wrote:
Hi All;

Using libxml, I've parsed out the fields using the tree1 example, but I
can't figure out how to rewind the stream, so I can start looking for a
different block. I have ~12 programs that need to access different blocks so I'm thinking I'll make a parser.lib, but I need a way to rewind.
Any ideas?


I don't quite get "rewinding". How is it different from just reading
the file again?

--
William Park <op**********@yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/


I cant figure oput how to reread the file without closing it and reopening
it. I don't feel safe doing that because it would open the possibility that
someone could save a change between the close and open. I was hoping I could
either do something like ungetc, or rewind so the file stays locked by the
current user. This is on a system that camn have several engineers and a
tunnel controler all jockeying for position. Engineers around here don't
always wait their turns.
Is there a way using libxml to return to the start of the file and search
the tree again for a different set of data?
Pat
Jan 16 '06 #5
Pat Ford <pa******@nrc.ca> wrote:

"William Park" <op**********@yahoo.ca> wrote in message
news:b6**************************@PRIMUS.CA...
Pat Ford <pa******@nrc.ca> wrote:
Hi All;

Using libxml, I've parsed out the fields using the tree1 example, but I
can't figure out how to rewind the stream, so I can start looking for a
different block. I have ~12 programs that need to access different blocks so I'm thinking I'll make a parser.lib, but I need a way to rewind.
Any ideas?


I don't quite get "rewinding". How is it different from just reading
the file again?

--
William Park <op**********@yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/


I cant figure oput how to reread the file without closing it and reopening
it. I don't feel safe doing that because it would open the possibility that
someone could save a change between the close and open. I was hoping I could
either do something like ungetc, or rewind so the file stays locked by the
current user. This is on a system that camn have several engineers and a
tunnel controler all jockeying for position. Engineers around here don't
always wait their turns.
Is there a way using libxml to return to the start of the file and search
the tree again for a different set of data?
Pat


How about temporary file, or reading the file into memory? If you're at
C level, you can do rewind(3) which is a frontend for fseek(3).

--
William Park <op**********@yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
Jan 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
21494
by: MrBill | last post by:
I would like to be able to open, read, and extract data from a report that is produced in MS Word. The doc seems to contain embedded spreadsheets. I would like to extract some of the data from...
2
2291
by: Peter Sprenger | last post by:
Hello, I hope somebody can help me with my problem. I am writing Zope python scripts that will do parsing on text for dynamic webpages: I am getting a text from an oracle database that contains...
3
3481
by: Pir8 | last post by:
I have a complex xml file, which contains stories within a magazine. The structure of the xml file is as follows: <?xml version="1.0" encoding="ISO-8859-1" ?> <magazine> <story>...
4
5234
by: Earl | last post by:
I'm curious if there are others who have a better method of accepting/parsing phone numbers. I've used a couple of different techniques that are functional but I can't really say that I'm totally...
4
4841
by: Rick Walsh | last post by:
I have an HTML table in the following format: <table> <tr><td>Header 1</td><td>Header 2</td></tr> <tr><td>1</td><td>2</td></tr> <tr><td>3</td><td>4</td></tr> <tr><td>5</td><td>6</td></tr>...
9
4041
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
3
4356
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
13
4473
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
6
3496
by: James Arnold | last post by:
Hello, I am new to C and I am trying to write a few small applications to get some hands-on practise! I am trying to write a random string generator, based on a masked input. For example, given...
1
2845
by: Philip Semanchuk | last post by:
On Oct 12, 2008, at 5:25 AM, S.Selvam Siva wrote: Selvam, You can try to find them yourself using string parsing, but that's difficult. The closer you want to get to "perfect" at finding URLs...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7126
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.