Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding special characters

 
Nits Kulkarni
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
sample.xml
--------------------
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="#!-- #TEMPLATES:/os_files/document.xsl --#"?>
<body>
<head type="title">INTRODUCTORY NOTE</head>
<p>Bacon’s literary executor, Dr. Rowley, published "The New Atlantis" in 1627, the year after the author’s death.
</p>
</body>

i am applying DocumentBuilder for parsing above xml file. I need to read the special characters "’s" as it is, but when i read the attribute value these characters are truncated.Can you please tell how to read everything under <p> </p> tag as it is?

Thanks in advance
Nits
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attribute value? I don't see any instances of "'s" in an attribute there. There's only one, and it's in a text node, not in an attribute.

My guess is that you are using SAX to parse this XML, and you are incorrectly assuming that the characters() method returns the text node all in one piece. But the parser is allowed to break the text node into more than one piece and call the characters() method once for each piece. Is that a correct guess?
 
Nits Kulkarni
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Sorry, the special characters i mentioned here has been truncated by javaranch.
I am using DOM parser. And anything i get in between <p></p> tag should be read without resolving any special characters.
Let me try to give you the special character here,it is: "’"
hp this is not truncated again.

Regards
Nitin
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nits Kulkarni:
And anything i get in between <p></p> tag should be read without resolving any special characters.
Let me try to give you the special character here,it is: "’"
hp this is not truncated again.
Yes, I know when character you were talking about. An XML attribute is where you put name="value" inside the start tag of an element. It's misleading when you start talking about text nodes as "attributes".

Now, what do you mean by "resolve" there? Does your XML document contain the seven characters "&#8217;" and you don't want the parser to interpret that as a curly quote character? It would help if you could provide a clear question because this is the second guess I have made at your problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic