• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Parsing Values with Squre Brackets

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
We begin by testing your absorbancy by exposing you to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic