?
Solved

Updating DDSDocValue  text in XML

Posted on 2009-02-18
14
Medium Priority
?
313 Views
Last Modified: 2013-12-22
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

0
Comment
Question by:tia_kamakshi
  • 8
  • 6
14 Comments
 
LVL 92

Expert Comment

by:objects
ID: 23677090
try using xsl

where are the email addresses coming from?

0
 

Author Comment

by:tia_kamakshi
ID: 23679176
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
 

Author Comment

by:tia_kamakshi
ID: 23685222
Hi,

Is my question that hard??
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 23686560
0
 

Author Comment

by:tia_kamakshi
ID: 23687880
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
 
LVL 92

Expert Comment

by:objects
ID: 23687921
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
 

Author Comment

by:tia_kamakshi
ID: 23690985
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
 
LVL 92

Expert Comment

by:objects
ID: 23702752
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
 

Author Comment

by:tia_kamakshi
ID: 23739878
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
 
LVL 92

Expert Comment

by:objects
ID: 23739932
whats wrong with using DOM?

0
 

Author Comment

by:tia_kamakshi
ID: 23747169
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
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 23750562
0
 

Author Comment

by:tia_kamakshi
ID: 23754215
Yes, Many Thanks...

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

Many Thanks again

Kind Regards
0
 

Author Closing Comment

by:tia_kamakshi
ID: 31548540
Many Thanks. Its great
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month16 days, 12 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question