You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Cristina Cioroboiu <cr...@yahoo.com> on 2004/05/19 08:41:51 UTC

how to change the value of a specific node

I have a DOMDocument.
I use Xalan to determine a specific section of an DOMDocument (Xpath 
determined). I want  encode this in Base64 ( the element and probably its descendants ).
 
I have the node now and I want to replace with  this new value the corresponding element (tree) in the original DOMDocument. Can you help me?

Many thanks.
Cristina


		
---------------------------------
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.

Re: how to change the value of a specific node

Posted by Cristina Cioroboiu <cr...@yahoo.com>.
We need to post some xml documents  in db2 database.  
 
I need a part of the message, that structure to go in a column. the rest of the elements will go every one in his column. I didn't find for db2 only 2 ways to work with xml ( an xml column or spread xml simple elements into differents column). i dind't find a way to mix them ( a compound element to a column ).
 
Thanks, you were very helpful.
Gareth Reakes <ga...@parthenoncomputing.com> wrote:
Hey,
in that case, take a look at the serializer (DOMWriter). Write in
to memory, encode it. Take original, delete all its child nodes and add
the text node you created when encoding. Be aware of issues like namespace
normalization (take a look at normalize document) if you are are going to
process the document before expanding the nodes.

On a side issue, this does seem slightly evil. Why do you have to
do it?

Gareth



On Wed, 19 May 2004, Cristina Cioroboiu wrote:

> Thanks Gareth.
>
> I have this structure as partof my main document:
>
> 
> value 1 
> value 2 
> .....
> value n 
> 
>
> I want to take this structure and encode it in Base 64.
>
> I serialize this and I want to obtain
> 
> Base64 value
> 
> as a part of my main document.
>
> After some processing I want to decode and come back to my old document structure.
>
> My problem is this replace of the structure in the main document.
>
>
>
> ---------------------------------
> Do you Yahoo!?
> SBC Yahoo! - Internet access at a great low price.

-- 
Gareth Reakes, Managing Director Parthenon Computing
+44-1865-811184 http://www.parthcomp.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

		
---------------------------------
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.

Re: how to change the value of a specific node

Posted by Gareth Reakes <ga...@parthenoncomputing.com>.
Hey,
	in that case, take a look at the serializer (DOMWriter). Write in
to memory, encode it. Take original, delete all its child nodes and add
the text node you created when encoding. Be aware of issues like namespace
normalization (take a look at normalize document) if you are are going to
process the document before expanding the nodes.

	On a side issue, this does seem slightly evil. Why do you have to
do it?

Gareth



On Wed, 19 May 2004, Cristina Cioroboiu wrote:

> Thanks Gareth.
>
> I have this structure  as partof my main document:
>
> <Original>
>         <Node1> value 1 </Node1>
>         <Node2> value 2 </Node2>
>         .....
>         <Noden> value n <Node n>
> </Original>
>
> I want to take this structure and encode it in Base 64.
>
> I serialize this and I want to obtain
> <Original>
>      Base64 value
> </Original>
> as a part of my main document.
>
> After some processing I want to decode and  come back to my old document structure.
>
> My problem is this replace of the structure in the main document.
>
>
>
> ---------------------------------
> Do you Yahoo!?
> SBC Yahoo! - Internet access at a great low price.

-- 
Gareth Reakes, Managing Director      Parthenon Computing
+44-1865-811184                  http://www.parthcomp.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: how to change the value of a specific node

Posted by Cristina Cioroboiu <cr...@yahoo.com>.
Thanks Gareth.
 
I have this structure  as partof my main document:
 
<Original>
        <Node1> value 1 </Node1>
        <Node2> value 2 </Node2>
        .....
        <Noden> value n <Node n>
</Original>
 
I want to take this structure and encode it in Base 64.
 
I serialize this and I want to obtain 
<Original>
     Base64 value
</Original>
as a part of my main document. 
 
After some processing I want to decode and  come back to my old document structure.
 
My problem is this replace of the structure in the main document.
 

		
---------------------------------
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.

Re: how to change the value of a specific node

Posted by Gareth Reakes <ga...@parthenoncomputing.com>.
Hi,
	I don't fully understand what you are asking, but I will have a go
at answering. When you say you want to base64 encode an element and its
descendants, I assume you mean the text content of them? If so you can call
getTextContext. If not you will have to serialize and then encode. For the
second part I think you mean "how do I replace an element with a new
string (which happens to be the base 64 encoded representation). For that,
you get the parent of the element, use the parent to delete the element,
and then add the text as a text node.

I have have misunderstood you please feel free to reply.

Gareth


On Tue, 18 May 2004, Cristina Cioroboiu wrote:

> I have a DOMDocument.
> I use Xalan to determine a specific section of an DOMDocument (Xpath
> determined). I want  encode this in Base64 ( the element and probably its descendants ).
>
> I have the node now and I want to replace with  this new value the corresponding element (tree) in the original DOMDocument. Can you help me?
>
> Many thanks.
> Cristina
>
>
>
> ---------------------------------
> Do you Yahoo!?
> SBC Yahoo! - Internet access at a great low price.

-- 
Gareth Reakes, Managing Director      Parthenon Computing
+44-1865-811184                  http://www.parthcomp.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org