Help wanted in getting value from xml tag using java
Hi,
I am using JDOM to get the values from the XML.
My xml has a tag with value as:
<map>PIM ©</map>
I use,
IConfigElement mapElement = lookupElement("map");
String map = mapElement.getValue();
The value is get is 'PIM ?/b> ', i dont want this value.
My requirement is to get the original String not the ascii value.
Any idea how to get it.
thanks
Your entry makes little sense.
When you specify some string with ampersands in it, HTML gets in the way and translates your nice string of whatever into its value.
If you want to post a string, for exmaple the way to specify an ampersand in
HTML, do something like "ampersand-a-m-p-semicolon" and that will be clear to those who may help you.
Dave Patterson
Hi,
I am using JDOM to get the values from the XML.
My xml has a tag with value as:
<map>PIM & #169;</map>
If u dont see the value properly, the value in the tag is
ampersand#169;
I use,
IConfigElement mapElement = lookupElement("map");
String map = mapElement.getValue();
The value is get is ' PIM ?', i dont want this value.
My requirement is to get the original String not the ascii value.
Any idea how to get it.
thanks
I've used JDom quite a lot, but am unfamiliar with the IConfigElement. But, the JavaDocs for JDom say that the getValue() is used to return a XPath string. I've always used getText() to get the contents of an element.Dave Patterson
> <map>PIM & #169;</map>
Assuming there is really no space between the & and the #, and you put that there to get around the forum's escaping of escape sequences: that text node consists of five characters. They are "P", "I", "M", space, and U+00A9. You have used a Unicode escape sequence for the last of the five characters, resulting in the copyright symbol. So as far as XML is concerned, it's five characters and not the 10 characters you typed to represent those five characters.
So what's your problem? I suspect you don't really have a technical problem, but you are just confused about what Unicode escape sequences mean in XML.
No i am not confused,my requirement is to get the exact value of the <map> tag no matter what is written inside.
I know that last five characters are unicode escape characters but i dont want that i want that XML overcome it and give me the value.
In short i want the value as PIM & #169; and not as PIM ©
I put some space between & and # but in real its not.
thanks
You aren't allowed to have that requirement if you're working with XML. If you don't want to follow XML's rules (in particular the character interpretation rules that I explained) then you can't use standard XML parsers to process the XML. You'll have to write your own parser which parses your non-standard language that's based on XML.
But you don't want to do that. Perhaps you could explain where this requirement comes from and why it exists.