writing Nodes

View: New views
4 Messages — Rating Filter:   Alert me  

writing Nodes

by Lev Lvovsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

Upon parsing an XML file with the Xerces DOM parser, there may be  
times when I want to recreate and eventually print the XML of a  
particular DOMNode, as well as it's parent entities.  Other than  
piecing together the XML string as I traverse the structure, is there  
any Xerces function which would allow me to print out only the  
DOMElements/Nodes leading to a particular node from the root of the  
document?

As an example, assuming this is my XML:

<fruit>
   <description>
     <name>banana</name>>
     <color>yellow</color>
   </description>
   <description>
     <name>strawberry</name>
     <color>red</color>
   </description>
</fruit>

If for instance, I wanted to print out all of the XML related to the  
banana, and end up with a result like:

<fruit>
   <description>
     <name>banana</name>>
     <color>yellow</color>
   </description>
</fruit>

Are there any existing functions which can do this, or do I need to  
piece it together on my own?

thanks!
-lev

---------------------------------------------------------------------
To unsubscribe, e-mail: p-dev-unsubscribe@...
For additional commands, e-mail: p-dev-help@...


Re: writing Nodes

by Jason Stewart-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Lev,

On 7/25/07, Lev Lvovsky <lists2@...> wrote:

> Are there any existing functions which can do this, or do I need to
> piece it together on my own?
>

There is nothing directly. You would have to define something using
the DOM methods are using a DOMTreeWalker possibly.

Cheers, jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: p-dev-unsubscribe@...
For additional commands, e-mail: p-dev-help@...


Re: writing Nodes

by Lev Lvovsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jason,

On Jul 24, 2007, at 10:48 PM, Jason Stewart wrote:

> Hi Lev,
>
> On 7/25/07, Lev Lvovsky <lists2@...> wrote:
>
>> Are there any existing functions which can do this, or do I need to
>> piece it together on my own?
>>
>
> There is nothing directly. You would have to define something using
> the DOM methods are using a DOMTreeWalker possibly.

I've decided that since I'm looping through the elements in the file  
that I'm parsing, that I might as well construct a duplicate document  
with only the child elements that I want (those whose data is  
incorrect).

I'm having some problems in creating this document, and wanted to  
just run by the process that I'm going through for some possible  
corrections.  Effectively I'm going off of the sample code,  
specifically DOMCreate.pl.

1.  The file which I'm parsing does not directly mention any DOCTYPE  
(as defined in the call to createDocumentType()).  Can I also omit  
it's inclusion from the document which I'm creating?

2.  after I've created the document with a fake doctype, I proceed to  
clone a node which I'm interested (I'm assuming I need to clone the  
node, as opposed to simply adding it to the new document), and then  
append it to the document.  I get the following error: "A attempt was  
made to insert a node where it is not permitted".  Do I need to cast  
the DOMNode as an element somehow, or?

any help would be appreciated - if there's a user guide to Xerces,  
that would be even more appreciated!

thanks,
-lev

---------------------------------------------------------------------
To unsubscribe, e-mail: p-dev-unsubscribe@...
For additional commands, e-mail: p-dev-help@...


Re: writing Nodes

by Jason Stewart-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Lev,

On 7/26/07, Lev Lvovsky <lists2@...> wrote:

> any help would be appreciated - if there's a user guide to Xerces,
> that would be even more appreciated!

I would love to produce a users guide to Xerces-P (there is one for
Xerces-C), but that would take quite a bit of time ... I was hoping to
get the BBC to fund that, but it didn't happen. It would also be
possible to have someone else write up the guide, and I can suggest
and edit it. I'm open for other possibilities as well!

Cheers, jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: p-dev-unsubscribe@...
For additional commands, e-mail: p-dev-help@...

LightInTheBox - Buy quality products at wholesale price!