Link to home
Start Free TrialLog in
Avatar of Ian MacRae
Ian MacRae

asked on

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.
Avatar of LajuanTaylor
LajuanTaylor

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?
Avatar of Ian MacRae

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of LajuanTaylor
LajuanTaylor

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@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.