You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Joakim Löfgren (ERA)" <Jo...@era.ericsson.se> on 2001/10/04 14:40:07 UTC

RE: Parsing special charcters - the Solution

For those interested:
With the help from John Snelson I found out that the entity reference is a
separate node in itself. So instead of using my original code:

  Text valueText = (Text)valueElt.getFirstChild();
  String value = valueText.getData().trim();
  
I had to create a loop like this:

  elts = valueElt.getChildNodes();
  for(int i = 0; i < elts.getLength(); i++){
      valueText = (Text)elts.item(i);
      value += valueText.getData().trim();
  }

And everything works out!

Thanks for the help John.

--- jsl ---


>Hi
>I'm new to the list and I've got a problem. 
>I export an XML-file with the help from Xerces, and if there 
>is an ampersand
>in a String I replace it with &amp;. 
>This works fine but when I parse the file with a DOMParser the 
>Value of the
>string ends right where the &amp; begins, example:
>
>	String a = "hc543&65"
>
>is being converted to 
>
>	a = "hc543&amp;65"
>
>When I parse the exported XML-file the value of the String is 
>
>	"hc543"
>
>Why doesn't the parser convert the &amp; to an ampersand, &, 
>like it should?
>
>Thanks
>
>--- jsl ---

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org