Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

xml in 1.5...

Thread view: 
puzzlecracker - 19 Feb 2006 15:46 GMT
et's say I have the following xml file within namspace (i am not
including it below)
<info>
     <item>
      <id>566</id>
     ............
     </item>

     <item>
     <id>665</id>
     ............
     </item>

     <item>
       <id>675</id>
     ............
     </item>

</info>

I want to extract  each< item> in its entirity; thus,  in above, I want
to create  3 files  names 566.xml, 655.xml: that is named after id in
each item, and
each containing just
      <item>
     ............
     </item>

.I tried using xpath didnt help, not sure how to readof the actual
tags.
Raymond DeCampo - 19 Feb 2006 18:53 GMT
> et's say I have the following xml file within namspace (i am not
> including it below)
[quoted text clipped - 26 lines]
> .I tried using xpath didnt help, not sure how to readof the actual
> tags.

Probably the best approach here is to use the DOM to create the new
documents.  There are methods (the exact names escape me at the moment)
to clone or copy elements from one document to another.  Then the
problem is getting a text representation of the new documents.  For some
reason there is not a direct way of doing this.  The best way is to use
the javax.transform.Transformer class with a trivial transform and a
StreamResult pointing to your file.

HTH,
Ray
Signature

This signature intentionally left blank.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.