Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-11

laz2_xmlread and & text

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

Consider this XML:

?<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 3.0//EN" "http://www.w3.org/TR/MathML3/dtd/mathml3.dtd">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mi>&pi;</mi>
<mo>&InvisibleTimes;</mo>
<msup>
<mi>r</mi>
<mn>2</mn>
</msup>
</math>

I cannot get the value "&pi;" because TXMLReader.ParseRef as far as I can tell will substitute it with an empty string =(

How can I get "&pi;" or at least the Unicode char for Pi? Maybe I should add a field to allow me to define my own ParseRef routine? This way I could in my own code fix this. I guess I could change ParseRef to substitute &pi; with pi, but this could lead to an endless amount of combinations which could be valid.... and all of them need to be added to ParseRef.

thanks,

Felipe Monteiro de Carvalho

Reply by email

Mattias Gaertner
to Felipe Monteiro de Carvalho
Show quoted text 24 lines
Hello, Consider this XML: ?<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 3.0//EN" "http://www.w3.org/TR/MathML3/dtd/mathml3.dtd"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>&pi;</mi> <mo>&InvisibleTimes;</mo> <msup> <mi>r</mi> <mn>2</mn> </msup> </math> I cannot get the value "&pi;" because TXMLReader.ParseRef as far as I can tell will substitute it with an empty string =( How can I get "&pi;" or at least the Unicode char for Pi? Maybe I should add a field to allow me to define my own ParseRef routine? This way I could in my own code fix this. I guess I could change ParseRef to substitute &pi; with pi, but this could lead to an endless amount of combinations which could be valid.... and all of them need to be added to ParseRef.

The &pi; corresponds to a TDOMEntityReference and NodeName contains the "pi".

  for Node in doc.GetEnumeratorAllChildren do begin
    DbgOut(Space(Node.GetLevel*2+2));
    DbgOut(DbgSName(Node));
    if Node is TDOMText then
      DbgOut(':"',TDOMText(Node).TextContent,'"')
    else
      DbgOut(':',Node.NodeName);
    debugln;
  end;

Mattias

Reply by email