ikorin24 / U8XmlParser

Extremely fast UTF-8 xml parser library
MIT License
95 stars 13 forks source link

Feature Request: Support for mixed content #19

Closed SebastianStehle closed 2 years ago

SebastianStehle commented 2 years ago

Afaik the normal xml is totally valid.

<div>
<strong>Hello</strong> U8XMLParser
</div>

But in this case I have no idea how to get the inner xml.

ikorin24 commented 2 years ago

Thank you for the report.

I did not consider nodes that have both nodes and text in their child elements. The parser implementation needs to be corrected.

SebastianStehle commented 2 years ago

Great work btw. As I said in the other issue we are working on a MJML port and this library gives us a 20% performance speed. OR would give us...

SebastianStehle commented 2 years ago

Btw: Do you also support comments?

ikorin24 commented 2 years ago

@SebastianStehle The parser skips comments, so you can't get any information in it. But you can parse it by yourself from the string XmlObject.AsRawString() or XmlNode.AsRawString() methods return.

SebastianStehle commented 2 years ago

I have special "raw" nodes and for these raw nodes I just need to print the output directly. Something like

<mj-raw>
  <!-- Comment -->
  <hr /> 
  Foobar
</mj-raw>

If I can somehow get the inner content it works fine for me.

ikorin24 commented 2 years ago

Try out the following code.

XmlNode mj_raw = ...;  // <mj-raw> node
RawString str = mj_raw.AsRawString();
Console.WriteLine(str);

The output is

<mj-raw>
  <!-- Comment -->
  <hr /> 
  Foobar
</mj-raw>

Is this what you want ?

If you want to get the content of mj-raw node, you should slice the RawString.

SebastianStehle commented 2 years ago

Awesome :)