You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by "Coker, Jonathan M" <jo...@boeing.com> on 2007/05/22 21:49:28 UTC

Parsing but want to save the orignal XML

Hello,
  I am parsing a file with data of the form
<DataStream>
<PlayerData id = "1">
    <x>100</x>
    <y>50</y>
    <z>75</z>
</PlayerData>
<PlayerData id = "2">
    <x>100</x>
    <y>50</y>
    <z>75</z>
</PlayerData>
.
.
.
.

<DataStream>

with PlayerData repeated over and over.  I would like to use SAX to
parse it but retain the original XML to send elsewhere. Is this
possible?

Thank you


RE: Parsing but want to save the orignal XML

Posted by Kosaraju Karuna-C9013Z <C9...@motorola.com>.
Yes, It is possible with the DOM and SAX to parse the XML having below
representation.
With the SAX, you can override startElement, endElement, characters
etc., APIs to parse the XML.Refer to the SAX documentation for more
information on SAX APIs. 

Also, with the DOM, the input XML will still be retained unless you
perform some changes to the DOM tree in memory and save the changes to
file. If the parsing involves only READ operation, I prefer SAX. If it
involves both READ and WRITE, DOM is the correct choice

Hope that helps.

Thanks,
Karuna 



-----Original Message-----
From: Coker, Jonathan M [mailto:jonathan.m.coker@boeing.com] 
Sent: Tuesday, May 22, 2007 2:49 PM
To: c-users@xerces.apache.org
Subject: Parsing but want to save the orignal XML

Hello,
  I am parsing a file with data of the form <DataStream> <PlayerData id
= "1">
    <x>100</x>
    <y>50</y>
    <z>75</z>
</PlayerData>
<PlayerData id = "2">
    <x>100</x>
    <y>50</y>
    <z>75</z>
</PlayerData>
.
.
.
.

<DataStream>

with PlayerData repeated over and over.  I would like to use SAX to
parse it but retain the original XML to send elsewhere. Is this
possible?

Thank you


RE: Parsing but want to save the orignal XML

Posted by "Coker, Jonathan M" <jo...@boeing.com>.
I am writing an app that will be consuming these PlayerData chunks as
they come in over the network.  Since I do not have the real (live)
source of the data available yet, I am trying to build a 'generator' to
simulate a stream by reading data from a file, packing it into a network
message and sending to my app. I wanted to take advantage of the
Start/End Element handlers to break up the file into the PlayerData
chunks that would form the message payload.  I know I could do this with
C++ streams but I already had all of the XML parsing, handlers, etc., in
place, just had to open the file.  
Also, any advice, links to patterns/examples, etc. about handling
incoming XML data like this would be appreciated.  I feel like there are
capabilities that I am not using or at least not using in the best way.
As always, thank you for your assistance.  (Sorry if this is a bit
scattered - trying to get it out before I have to go to a meeting.)

Jonathan


-----Original Message-----
From: David Bertoni [mailto:dbertoni@apache.org] 
Sent: Tuesday, May 22, 2007 3:01 PM
To: c-users@xerces.apache.org
Subject: Re: Parsing but want to save the orignal XML

Coker, Jonathan M wrote:
> Hello,
>   I am parsing a file with data of the form <DataStream> <PlayerData 
> id = "1">
>     <x>100</x>
>     <y>50</y>
>     <z>75</z>
> </PlayerData>
> <PlayerData id = "2">
>     <x>100</x>
>     <y>50</y>
>     <z>75</z>
> </PlayerData>
> .
> .
> .
> .
> 
> <DataStream>
> 
> with PlayerData repeated over and over.  I would like to use SAX to 
> parse it but retain the original XML to send elsewhere. Is this 
> possible?

Off the top of my head, I would say you could just send the file you're
parsing, but hopefully you meant something else.  Can you describe what
you want to do in more detail?

Dave

Re: Parsing but want to save the orignal XML

Posted by David Bertoni <db...@apache.org>.
Coker, Jonathan M wrote:
> Hello,
>   I am parsing a file with data of the form
> <DataStream>
> <PlayerData id = "1">
>     <x>100</x>
>     <y>50</y>
>     <z>75</z>
> </PlayerData>
> <PlayerData id = "2">
>     <x>100</x>
>     <y>50</y>
>     <z>75</z>
> </PlayerData>
> .
> .
> .
> .
> 
> <DataStream>
> 
> with PlayerData repeated over and over.  I would like to use SAX to
> parse it but retain the original XML to send elsewhere. Is this
> possible?

Off the top of my head, I would say you could just send the file you're 
parsing, but hopefully you meant something else.  Can you describe what you 
want to do in more detail?

Dave