@@ -570,3 +570,60 @@ fn issue683() {
570
570
}
571
571
) ;
572
572
}
573
+
574
+ /// Regression test for https://github.com/tafia/quick-xml/issues/868.
575
+ #[ test]
576
+ fn issue868 ( ) {
577
+ #[ derive( Debug , PartialEq , Deserialize ) ]
578
+ #[ serde( rename = "root" ) ]
579
+ pub struct Root {
580
+ #[ serde( rename = "key" ) ]
581
+ pub key : Key ,
582
+ }
583
+
584
+ #[ derive( Debug , PartialEq , Deserialize ) ]
585
+ #[ serde( rename = "key" ) ]
586
+ pub struct Key {
587
+ #[ serde( rename = "value" ) ]
588
+ pub values : Option < Vec < Value > > ,
589
+ }
590
+
591
+ #[ derive( Debug , PartialEq , Deserialize ) ]
592
+ #[ serde( rename = "Value" ) ]
593
+ pub struct Value {
594
+ #[ serde( rename = "@id" ) ]
595
+ pub id : String ,
596
+
597
+ #[ serde( rename = "$text" ) ]
598
+ pub text : Option < String > ,
599
+ }
600
+ let xml = r#"
601
+ <?xml version="1.0" encoding="utf-8"?>
602
+ <root>
603
+ <key>
604
+ <value id="1">text1</value>
605
+ <value id="2">text2</value>
606
+ <value id="3">text3</value>
607
+ <value id="4">text4</value>d
608
+ <value id="5">text5</value>
609
+ <value id="6">text6</value>
610
+ </key>
611
+ </root>"# ;
612
+ let result = quick_xml:: de:: from_str :: < Root > ( xml) ;
613
+ dbg ! ( & result) ;
614
+ assert_eq ! (
615
+ result. unwrap( ) ,
616
+ Root {
617
+ key: Key {
618
+ values: Some ( vec![
619
+ Value { id: "1" . to_string( ) , text: Some ( "text1" . to_string( ) ) } ,
620
+ Value { id: "2" . to_string( ) , text: Some ( "text2" . to_string( ) ) } ,
621
+ Value { id: "3" . to_string( ) , text: Some ( "text3" . to_string( ) ) } ,
622
+ Value { id: "4" . to_string( ) , text: Some ( "text4" . to_string( ) ) } ,
623
+ Value { id: "5" . to_string( ) , text: Some ( "text5" . to_string( ) ) } ,
624
+ Value { id: "6" . to_string( ) , text: Some ( "text6" . to_string( ) ) } ,
625
+ ] ) ,
626
+ } ,
627
+ }
628
+ ) ;
629
+ }
0 commit comments