Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-07-2008, 04:57 PM
Member
 
Join Date: Feb 2008
Posts: 1
iamhappy is on a distinguished road
Html tags within XML- need help
i am reading a database table and creating an XML. some of the values of the variables have html tags like <A href="www.yahoo.com">yahoo</A> . but after generating the XML i see the above value as
&lt;BR&gt;&lt;A href="http://www.yahoo.com"&gt;yahoo&lt;/A&gt;&lt;BR&gt;


is there any way that it can represent the actual html tags
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-09-2008, 07:04 PM
jelly's Avatar
Member
 
Join Date: Jan 2008
Location: Somerset, UK
Posts: 46
jelly is on a distinguished road
The reason that the conversion when the XML is written is is that the values you are trying to store are considered to be parsed data, i.e data that is the middle of a start and end tag, like the word FRED in the following

Code:
<Name> FRED </Name>
data stored in this way is looked at and parsed by XML parsers hence any '<' or '>' characters would cause problems ( the parser would not know whether a tag was starting or whether this was data. One way round this is to convert the < and > characters ( and some others ) to what are known as entities &lt; and &gt; which represent the less than and greater than symbols. This is what you seeing. Another way round the problem is to tell the parser _not_ to look at the data - then you can put there what you like, you do this by creating CDATA blocks which would look like the following for your example of an <a> tag

Code:
<SomeTag> <![CDATA <A href="www.yahoo.com">yahoo</A> ]]> </SomeTag>
__________________
-- Hope that helps
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-27-2008, 05:21 PM
DonCash's Avatar
Moderator
 
Join Date: Aug 2007
Location: London, UK
Posts: 223
DonCash will become famous soon enoughDonCash will become famous soon enough
How about using String replace?

Code:
if (yourString.contains("&lt;")){ yourString = yourString.replaceAll("&lt;","<"); } System.out.println(yourString);
You could read in the data and replace the characters then re-write out the .xml and everything will be correctly formatted.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sturts HTML Tags (II) JavaForums Java Blogs 0 01-17-2008 03:21 PM
Struts HTML Tags (I) JavaForums Java Blogs 0 01-17-2008 03:21 PM
HTML tags for Struts Java Tip Java Tips 0 12-27-2007 10:58 AM
Help with Tags JSP Marcus JavaServer Pages (JSP) and JSTL 2 07-04-2007 03:53 PM
How to parse HTML tags Ada Advanced Java 1 05-31-2007 10:42 PM


All times are GMT +3. The time now is 09:54 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org