Modifying XML in visual studio

I have a fairly simple XML file that is generated by an application every 2 seconds.
<root>
  <dataset1>
    <data>
      <field id="0">data field 1 data</field>
      <field id="1">data field 2 data</field>
    </data>
	</dataset1>
</root>

Open in new window


I have another application that needs it in a different format
<root>
	<finaldataset>
		<field_1>data field 1 data</field_1>
		<field_2>data field 1 data</field_2>
	</finaldataset>
</root>

Open in new window

Is there  a simple way that I can use visual studio to modify the xml without literally reading line by line and pumping out the new format. This way is inefficient as there are over a thousand fields.
LVL 1
Ian MacRaeSoftware ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LajuanTaylorCommented:
You can create an Integrated Services solution (SSIS) in Visual Studio that opens the door to many XML parsing options - XML Source Adapter, Script Task using C#, etc. An added benefit would be that you can easily schedule the solution to run automatically and include success or failure notifications.

Is SSIS in Visual Studio an option that you can consider using?
Ian MacRaeSoftware ConsultantAuthor Commented:
Considered SSIS, but given the number of elements (could extend to several thousands) and the quick read / write turnaround requirements, this was a little too slow. The source file is being rewritten every 2 seconds (at least) so it needs to be read, processed and saved within that timeframe.
LajuanTaylorCommented:
@idmacrae - With the potential of several thousands of elements how large are the XML files getting?

Is the source application also written in .NET?  If so, can you add a routine that makes a copy of the XML for use by the second application?

Secondly, have you considered creating a fast copy using c# to a temp directory first, then modify the XML for the second application to process.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ian MacRaeSoftware ConsultantAuthor Commented:
@LajuanTaylor
XML is from a proprietary (can't mention which one) monitoring sensor.  Depending on state, the number of elements varies greatly. If it in a really bad error state the number of nodes exceeds 10,000.  Normal is about 1,000.
Developers of source no longer available :(
My solution was similar to solution - used dedicated RAM to copy table, modified it and wrote out to SSD. Gets in just under 2 seconds.
Will mark your answer as accepted.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.