0

have Microsoft file (example below) - any parser will read the first root but ignore others looking for simple efficient solution, prefer to use Jackson XML with stream reader.

Working option i tested but don't like performance or effort wise: add fake root - need to rewrite to disk or keep whole file in memory custom parser - too much effort , less efficient than Jackson

Example file, this one is small but there are much lager ones:

<UpdateIdentity UpdateID="b2cf791b-250f-4559-8e26-c424c7cc8fba" RevisionNumber="101" /><Properties UpdateType="Software" ExplicitlyDeployable="true" /><Relationships><SupersededUpdates><UpdateIdentity UpdateID="d07d1e4c-f4f7-4cc4-b5fd-4a99c196829f" /></SupersededUpdates><Prerequisites><AtLeastOne><UpdateIdentity UpdateID="32b55feb-b5f5-47a7-8cc2-6a095c680267" /><UpdateIdentity UpdateID="0d27b716-280a-42a2-864a-bcd065c162e9" /></AtLeastOne><UpdateIdentity UpdateID="3e0afb10-a9fb-4c16-a60e-5790c3803437" /><AtLeastOne IsCategory="true"><UpdateIdentity UpdateID="0fa1201d-4330-4fa8-8ae9-b877473b6441" /></AtLeastOne><AtLeastOne IsCategory="true"><UpdateIdentity UpdateID="dbf57a08-0d5a-46ff-b30c-7715eb9498e9" /><UpdateIdentity UpdateID="7f44c2a7-bc36-470b-be3b-c01b6dc5dd4e" /></AtLeastOne></Prerequisites><BundledUpdates><AtLeastOne><UpdateIdentity UpdateID="27a8e21a-eba4-45a7-b63e-a7960b85fe31" RevisionNumber="101" /><UpdateIdentity UpdateID="307294f2-9ce0-44fb-b1f0-0b8a6cd7fc3d" RevisionNumber="101" /><UpdateIdentity UpdateID="bfe6cdba-e94d-4751-b288-b210d6f11e67" RevisionNumber="101" /><UpdateIdentity UpdateID="817db7e7-27b8-44f1-b087-5aa8c704e2f6" RevisionNumber="101" /><UpdateIdentity UpdateID="bdd98bb2-222e-4b7a-9e67-e1b317991b50" RevisionNumber="101" /><UpdateIdentity UpdateID="55ed1baa-1985-4af5-aaef-e34f4ecbb8c2" RevisionNumber="101" /><UpdateIdentity UpdateID="b92989aa-8456-4a3b-9392-6b0339124f11" RevisionNumber="101" /><UpdateIdentity UpdateID="f6449255-52f7-4391-8d08-f8e533331a77" RevisionNumber="101" /><UpdateIdentity UpdateID="400218ad-7d2b-46e9-8fab-26ee75589542" RevisionNumber="101" /><UpdateIdentity UpdateID="7e91b707-9705-4622-a57a-2aa36601ac73" RevisionNumber="101" /><UpdateIdentity UpdateID="79e300bf-f583-4423-b7ae-72082a521789" RevisionNumber="101" /><UpdateIdentity UpdateID="db673f2b-abce-4692-aea3-c2ef3bfc9b8b" RevisionNumber="101" /><UpdateIdentity UpdateID="6654b7c1-d9de-42c7-8650-612ce3f1ee1d" RevisionNumber="101" /><UpdateIdentity UpdateID="0600f544-04f2-4016-ba85-940add5287ae" RevisionNumber="101" /><UpdateIdentity UpdateID="2bd97156-28fb-4e33-9203-d4d71a0f6e92" RevisionNumber="101" /><UpdateIdentity UpdateID="7c84f31c-084e-43d6-bae9-f705b3354555" RevisionNumber="101" /><UpdateIdentity UpdateID="acba7ed2-4694-40d8-9334-a13eb151d1ca" RevisionNumber="101" /><UpdateIdentity UpdateID="ee700e3e-b7e3-4fa5-93b9-80bd21b189fc" RevisionNumber="101" /></AtLeastOne></BundledUpdates></Relationships> 
  • 1
    Do you have any control over the XML format? Multiple root tags in a document is bad form. If you can change the format, simply add a single parent tag to the docment wrapping the multiple roots to create children. – Ryan Feb 02 '22 at 19:29
  • nop, microsoft gives it like this - adding parent tag will require one of following 1. rewriting whole file to disk 2. keeping whole file in memory and both are expensive – Stack Underflow Feb 02 '22 at 19:32
  • 1
    @Ryan: It's worse than bad form. It's not XML. – kjhughes Feb 02 '22 at 19:37
  • @kjhughes I was being forgiving. OP says he's getting the document from Microsoft, I find it rather shocking a company like that would send out such response data. OP, You need to either get microsoft to fix their data or you'll need to prepocess the file to break it up into valid XML documents. – Ryan Feb 02 '22 at 19:39
  • @Ryan: Fair enough, and, right, even Microsoft wouldn't claim that's XML. – kjhughes Feb 02 '22 at 19:42

0 Answers0