Parsing with dxml
Joel
joelcnz at gmail.com
Tue Nov 19 04:43:31 UTC 2019
On Tuesday, 19 November 2019 at 02:45:29 UTC, Jonathan M Davis
wrote:
> On Sunday, November 17, 2019 11:44:43 PM MST Joel via
> Digitalmars-d-learn wrote:
>> [...]
>
> You need to be checking the type of the entity before you call
> either name or text on it, because not all entities have a
> name, and not all entities have text - e.g. <field name="id">
> is an EntityType.elementStart, so it has a name (which is
> "field"), but it doesn't have text, whereas the 01001001
> between the <field name="id"> and </field> tags has no name but
> does have text, because it's an EntityType.text. If you call
> name or text without verifying the type first, then you're
> almost certainly going to get an assertion failure at some
> point (assuming that you don't compile with -release anyway),
> since you're bound to end up with an entity that you don't
> expect at some point (either because you were wrong about where
> you were in the document, or because the document didn't match
> the layout that was expected).
>
> [...]
Thanks for taking the time to reply.
I have had another xml Bible version text in the past [1]. It had
a different format. And Adam Ruppe helped me by writing code that
worked (with just one tweak). I think I want another example that
I can just paste into my program, using the same structs as the
last xml version (see link).
[1] https://forum.dlang.org/thread/j7ljs5$24r2$1@digitalmars.com
More information about the Digitalmars-d-learn
mailing list