Skip to content

Parsing #PCDATA is impossible #34

@CJKay

Description

@CJKay

Hi, this crate is fantastic for parsing strictly-structured information, but in the XML documents that I'm using there are several tags which can contain mixed content (for rich-text renderers). For example, the DTD for one of these documents contains this para element description:

<!ELEMENT para (#PCDATA|image)*>

Which I would like to define with:

#[derive(Clone, Debug, XmlRead)]
#[xml(tag = "allinstrs")]
pub struct AllInstructions {
    #[xml(child = "para")]
    pub paragraph: Vec<ParagraphChild>,
}

#[derive(Clone, Debug, XmlRead)]
pub enum ParagraphChild {
    #[xml(tag = "image")]
    Image(Image),

    #[xml(text)]
    Text(String),
}

However, because derived enums cannot accept #[xml(text)] I cannot read in the text content. Is this a current limitation, or is there another strategy I'm not seeing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions