strong-xml icon indicating copy to clipboard operation
strong-xml copied to clipboard

Parsing #PCDATA is impossible

Open CJKay opened this issue 3 years ago • 0 comments

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?

CJKay avatar Mar 16 '22 13:03 CJKay