Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to parse tags with the same name but different children? #151

Open
miguelsilva5989 opened this issue Dec 5, 2022 · 1 comment
Labels
wait feedback The issue is addressed, wait a reply from the author

Comments

@miguelsilva5989
Copy link

miguelsilva5989 commented Dec 5, 2022

I'm having some trouble trying to find the best way of deserializing the following XML.
Inside TaskList the Task tags are the same but their inner children are different.
Is there any way of parsing this in order to differentiate between 2 tasks based on their class attribute?

I was playing around with Enums and such but I don't see any way of doing this except implementing the deserialize method manually. Was trying to find a similar example in the examples folder but I don't see nothing like this.

Thanks in advance
(I'm quite new to rust so I am sorry if this question seems silly)

<tasklist>
<task class="Aggregator" documentation="" name="Task Aggregator" taskkey="TaskAggregator" x="4000" y="640">
    <parameter name="Entity" type="Map">
        <parameter name="key" type="String">xxx</parameter>
        <parameter name="value" type="String">xxx</parameter>
    </parameter>
</task>
<task class="Transform" documentation="" name="Transform" taskkey="Transform" x="1440" y="560">
    <parameter name="Rules" type="Xml">
        <root advancedmode="false">\n    <set in="Flow" toValue="123" varType="String" variable="asd"></set>\n</root>
    </parameter>
</task>
</tasklist>
@MarcAntoine-Arnaud
Copy link
Contributor

Hello,

I you case I wanna to wrote like it to parse the XML:

Task {
  #[yaserde(attribute)]
  class: String,
  #[yaserde(attribute)]
  documentation: String,
  #[yaserde(attribute)]
  name: String,
  #[yaserde(attribute)]
  taskkey: String,
  #[yaserde(attribute)]
  x: usize,
  #[yaserde(attribute)]
  y: usize,
  parameter: Parameter
}

struct Parameter {
  #[yaserde(attribute)]
  name: String,
  #[yaserde(attribute)]
  type: String,
  parameters: Vec<Parameters>,
  root: Option<Root>,
}

is it relevant ?

@MarcAntoine-Arnaud MarcAntoine-Arnaud added the wait feedback The issue is addressed, wait a reply from the author label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wait feedback The issue is addressed, wait a reply from the author
Projects
None yet
Development

No branches or pull requests

2 participants