aspose file tools*
The moose likes XML and Related Technologies and the fly likes Parsing Values with Squre Brackets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Parsing Values with Squre Brackets" Watch "Parsing Values with Squre Brackets" New topic
Author

Parsing Values with Squre Brackets

Muhammad Mansoor.
Greenhorn

Joined: Oct 25, 2002
Posts: 8
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

Joined: Jan 23, 2002
Posts: 11962
    
    5
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?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Muhammad Mansoor.
Greenhorn

Joined: Oct 25, 2002
Posts: 8
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

Joined: Jan 23, 2002
Posts: 11962
    
    5
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

Joined: Oct 25, 2002
Posts: 8
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

Joined: Jan 23, 2002
Posts: 11962
    
    5
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:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parsing Values with Squre Brackets