Hi John,
I have a query regarding an use case of nested relation of nodes i.e. parent node has child, where child has parent node in it(<parent><child><parent></parent></child></parent>). Since expat is event based xml parser, I am new to use this library; now I would like to read and store the nested related elements data of a given xml. For example the structure of the xml is as shown below; In the below given sample xml data, <recipient> node is parent of <forwardto> node, where <forwardto> node is parent of <recipient> again.
Can Expat handle this scenario and reads out the data ? If yes, kindly suggest me with sample code using C++.</recipient></forwardto></forwardto></recipient>
<Recipient DeliveryType = "BCC">
<UserInfo>
<FirstName>Mahadev</FirstName>
<LastName>Kanike</LastName>
<FirmNumber>1219</FirmNumber>
<AccountName>IND</AccountName>
<AccountNumber>22222</AccountNumber>
</UserInfo>
<ForwardedTo>
<Recipient DeliveryType = "BCC">
<UserInfo>
<FirstName>NICK</FirstName>
<LastName>Dan</LastName>
<AccountName>UK</AccountName>
<AccountNumber>11111</AccountNumber>
</UserInfo>
</Recipient>
</ForwardedTo>
</Recipient>
Thanks in advance!
Best Regards,
Mahadev Kanike
Diff:
Expat does support files like that but building a tree structure during parser is in your hands.
I would expect classes close to
in your code and a stack of pointers to instances of Recipient during parsing. In the handlers, you build and walk that stack and create Recipients as you go. I hope that gets you started.
PS: For more support please contact me at firstname@lastname.org, please. I'll close this ticket as not-a-bug now.