Skip to content

text data in tag contents #868

@eirnym

Description

@eirnym

I have a data file which I cannot (shouldn't ask to) change:

<?xml version="1.0" encoding="utf-8"?>
<root>
	<key>
		<value id="1">text1</value>
		<value id="2">text2</value>
		<value id="3">text3</value>
		<value id="4">text4</value>d
		<value id="5">text5</value>
		<value id="6">text6</value>
	<key>
</root>

When I deserialize using quick-xml & serde, I have an error, with this d, which I'd love to ignore completely

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename = "root")]
pub struct Root {
  #[serde(rename = "key")]
  pub key: Key,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename = "key")]
pub struct Key {
  #[serde(rename = "value")]
  pub values: Option<Vec<Value>>
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename = "Value")]
pub struct Value {
  #[serde(rename = "@id")]
  pub id: String

  #[serde(rename = "$text")]
  pub text: Option<String>
}

Error I have and I'd like to ignore is Error: invalid type: string "d", expected struct Value

Metadata

Metadata

Assignees

No one assigned

    Labels

    arraysIssues related to mapping XML content onto arrays using serdebugserdeIssues related to mapping from Rust types to XML

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions