• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing Values with Squre Brackets

 
Muhammad Mansoor.
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have an generated XML via a legacy system, and i can not change the output of the legacy system. The part that is causing problems is :

<SYS_UNIQUE_NAME>[Alpha].[Level 04]</SYS_UNIQUE_NAME>

After parsing i get the value of the above node as :

[Alpha

XML Parser is trimming the vaule of the Node, any solution to this problem, so that i can read the full value ?


Thanks
mansoor
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting. I can't see any reason for the parser to do that. Which parser are you using and what does your code look like?
 
Muhammad Mansoor.
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Default JDK 1.4 Parser, I am iteraring a NodeList, from which one of the node contains these values.
[ June 23, 2004: Message edited by: Muhd. Mansoor ]
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very strange. Here's a JUnit test which I wrote and executed with the output shown below the code:

Here's the output:
 
Muhammad Mansoor.
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks A Lot

The mistake that i was making was getting the String direct from the Node and not by casting it in to Text

Thanks a Lot, Once Again !!!
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more thing:

should, in production quality code, not trust that the first child node is the one containing the text. Instead, you should iterate through all child nodes like this:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic