Updating DDSDocValue text in XML

Hi,

In an XML file

I need to update

<DDSDocValue name="Email" type="text" len=""></DDSDocValue>
to

<DDSDocValue name="Email" type="text" len="11">abc@def.com</DDSDocValue>

How can we do that

I have many many DDSDocValue in the XML

<DDSDocValue name="Email" type="text" len=""></DDSDocValue>
<DDSDocValue name="Subject" type="text" len=""></DDSDocValue>
<DDSDocValue name="AttachName1" type="text" len=""></DDSDocValue>

Thanks
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 
<!DOCTYPE eGAD SYSTEM "eGAD.Dtd">
<eGAD pakUID="">
<jobdata>
<datetime></datetime>
<JobName></JobName>
<JobShortName></JobShortName>
</jobdata>
<document docID="" docMasterID="" docInstanceID="">
<VendorId></VendorId>
<DocTypeId></DocTypeId>
<AccNo></AccNo>
<StmtDate></StmtDate>
<DDSDocValue name="Email" type="text" len=""></DDSDocValue>
<DDSDocValue name="Subject" type="text" len=""></DDSDocValue>
<DDSDocValue name="AttachName1" type="text" len=""></DDSDocValue>
<CustData>
<Name></Name>
<Addr line="1"></Addr>
<City></City>
<Region></Region>
<PostalCode></PostalCode>
</CustData>
<NumberOfPages value=""/>
</document>
</eGAD>

Open in new window

tia_kamakshiAsked:
Who is Participating?
 
objectsCommented:
try using xsl

where are the email addresses coming from?

0
 
tia_kamakshiAuthor Commented:
Can you please help me with XSL

I will pick email address and other values from database.

Then I have to save this xml file at different location

Thanks
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
tia_kamakshiAuthor Commented:
Hi,

Is my question that hard??
0
 
objectsCommented:
0
 
tia_kamakshiAuthor Commented:
Sorry, looks you didn't understood me

I donot have 2 xmls file

Suppose I have string str1, str2, str3 in java

I wish to update that string in below:

<DDSDocValue name="Email" type="text" len=""></DDSDocValue>
<DDSDocValue name="Subject" type="text" len=""></DDSDocValue>
<DDSDocValue name="AttachName1" type="text" len=""></DDSDocValue>

just wish to update len abd text in the above nodes

<DDSDocValue name="Email" type="text" len="str1">str2</DDSDocValue>
<DDSDocValue name="Subject" type="text" len="str4">str3</DDSDocValue>
<DDSDocValue name="AttachName1" type="text" len="str5">str6</DDSDocValue>

Rest XMLformat is in my opening question

Many Thanks
0
 
objectsCommented:
I did realise that, and to sue xsl you'll need to export your data from database into an xml file that can be merged with your template.

Other approach would be to do the merge manually by building a DOM document based on what was read from the database. Something like stax could also be used.

0
 
tia_kamakshiAuthor Commented:
Thanks,

Yes DOM approach is fine to me. Do you have something in DOM to help me with it

Many Thanks again for your co-operation
0
 
objectsCommented:
not a lot handy sorry.
the following shows how to read xml into a dom
http://helpdesk.objects.com.au/java/how-do-i-create-a-dom-document-from-an-xml-file

and some more DOM examples herehttp://www.exampledepot.com/egs/org.w3c.dom/pkg.html

0
 
tia_kamakshiAuthor Commented:
Then what is the best way to do it. If DOM is not good example

Can Xpath help

Please guide me the best way

Many Thanks
0
 
objectsCommented:
whats wrong with using DOM?

0
 
tia_kamakshiAuthor Commented:
Thanks for your reply,
Because no where in above example I am given solution to update

My elements in XML file (XML format is shown above)

which are
 wish to update that string in below:

<DDSDocValue name="Email" type="text" len=""></DDSDocValue>
<DDSDocValue name="Subject" type="text" len=""></DDSDocValue>
<DDSDocValue name="AttachName1" type="text" len=""></DDSDocValue>

just wish to update len abd text in the above nodes

<DDSDocValue name="Email" type="text" len="str1">str2</DDSDocValue>
<DDSDocValue name="Subject" type="text" len="str4">str3</DDSDocValue>
<DDSDocValue name="AttachName1" type="text" len="str5">str6</DDSDocValue>


I dont matter where I get it done from DOM, Xpath or by some other way.

Many Thanks again for your response
0
 
tia_kamakshiAuthor Commented:
Yes, Many Thanks...

This looks cool to me. I will come back to you let me test.

Many Thanks again

Kind Regards
0
 
tia_kamakshiAuthor Commented:
Many Thanks. Its great
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.