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 / January 2006

Tip: Looking for answers? Try searching our database.

XML element as string??

Thread view: 
keshawra - 23 Jan 2006 05:19 GMT
Hi ,

I need to parse this XML using DOM in java.

<Replace><img src="/topcoder/images/smiles/base_smile.gif" border="0"
alt="smile"/></Replace>

have to get everyhing under "Replace" as String. i.e., replaceString =
"<img src="/topcoder/images/smiles/base_smile.gif" border="0"
alt="smile"/>"

JAXP is considering "img" as an element node as it is supposed to do.

can anyone suggest me???

kiri
zero - 23 Jan 2006 14:01 GMT
keshawra <keshwara@cyberwerx.com> wrote in news:1137993343.720288@sj-
nntpcache-5:

> Hi ,
>
[quoted text clipped - 12 lines]
>
> kiri

If <Replace> is supposed to hold strings, then your XML is flawed.  The DTD
or Schema should complain that <Replace> should not contain other elements.  
In other words: change the XML to use escape sequences (entity references)
instead of <, > and ".  Alternatively, use a CDATA section.

If you cannot correct the XML file, you're probably going to need to find a
programmatic solution.  One solution, although not very pretty, is just to
accept JAXP's output, and convert any elements within a <Replace> element
back to Strings.


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



©2008 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.