PDA

View Full Version : splitting an xml file into several and merging several xml files



BukhtiarM
18 Aug 2014, 3:57 AM
I want to read an xml file from the server and then split it into several files also add some data that is not even present in the first file (possibly merge other xml data), into the file. So I have a large xml file on the server and depending upon what the user has requested i want to output some part of that file to the server and run a different program to process the output later. Could someone please point out what i need to read to be able to do this. I have gone through the api docs for xml writer and reader and it didnt help much. I have also seen several examples but no one apparently has done something like i need to do. I would be grateful if some one could help me a little bit.

Here is how the original file looks like.


<?xml version='1.0' standalone='yes'?><Acrolein>
<Name>
Acrolein
</Name>
<H_Class>
<Health>
<level>4</level>
<comment>Can be lethal.</comment>
</Health>
<Flammability>
<level>3</level>
<comment>Can be ignited under almost all ambient temperature conditions.</comment>
</Flammability>
<Instability>
<level>3</level>
<comment>
<ol>
<li>Conditions contributing to instability: Heat, sparks, or open flame. The vapors of acrolein form explosive mixtures with air.</li>
<li>Incompatibilities: Acrolein is very reactive and polymerizes rapidly and violently in the presence of strong acid or basic catalysts, light, heat, and volatile amines.</li>
<li>Upon storage, it forms shock-sensitive and heat-sensitive explosive compounds. Fire and explosions may result from contact of acrolein with oxidizers, acids, alkalies, or ammonia.</li>
<li>Hazardous decomposition products: Toxic gases and vapours, including peroxides and oxides of carbon, may be released in a fire involving acrolein.</li>
<li>Special precautions: An inhibitor, usually hydroquinone, should be added to this highly unstable material to prevent self-polymerization.</li>
</ol>
</comment>
</Instability>
</H_Class>
<limits>
<TWA>
<value>0.1</value>
<description>Time Weighted Average (8 hours)</description>
</TWA>
<Ceiling>
<value>0</value>
<description>Immediately dangerous to Life or Health</description>
</Ceiling>
<STEL>
<value>0.3</value>
<description>Immediately dangerous to Life or Health</description>
</STEL>
<IDLH>
<value>2</value>
<description>Immediately dangerous to Life or Health</description>
</IDLH>
<LFL>
<value>28000</value>
<description>Immediately dangerous to Life or Health</description>
</LFL>
<UFL>
<value>310000</value>
<description>Immediately dangerous to Life or Health</description>
</UFL>
<Toxic_Endpoint>
<value>0.48</value>
<description>Immediately dangerous to Life or Health</description>
</Toxic_Endpoint>
<ERPG1>
<value>0.05</value>
<description>Immediately dangerous to Life or Health</description>
</ERPG1>
<ERPG2>
<value>0.15</value>
<description>Immediately dangerous to Life or Health</description>
</ERPG2>
<ERPG3>
<value>1.5</value>
<description>Immediately dangerous to Life or Health</description>
</ERPG3>
<Flammability>
<value>1</value>
<description>Immediately dangerous to Life or Health</description>
</Flammability>
<Combustion>
<value>29000</value>
<description>Immediately dangerous to Life or Health</description>
</Combustion>
<lethal>
10
</lethal>
</limits>
<Response>
<Fire>
<ThreatL1>
<ol>
<li>The acrolein concentration is safe for operations, but being highly flammable and explosive extreme precaution is advised.</li>
<li>Containers may explode in fire. Should be removed if possible safely.</li>
<li>If not cool containers using water</li>
<li>Combat fires from safe distance or protected location preferably upwind.</li>
</ol>
<Public>Sheltering indoors and keep windows closed for up to</Public>
</ThreatL1>
<ThreatL2>
<ol>
<li>Unsafe levels of Acrolein detected take extreme care and wear appropriate personal protection before entering the region</li>
<li>Poisonous gases are produced when heated use appropriate breathing apparatus.</li>
<li>Combat fires from safe distance or protected location preferably upwind.</li>
<li>Containers may explode in fire. Should be removed if possible safely.</li>
<li>Flashback along vapor trail may occur.</li>
<li>Water may be ineffective on fire, but can be used for cooling the containers and suppressing vapours</li>
</ol>
</ThreatL2>
<ThreatL3>
<ol>
<li>Lethal concentrations of Acrolein in the environment</li>
<li>The suggested Personal Protective equipment might not be good enough for more than an hour</li>
<li>Evacuate all in a 10 km radius</li>
</ol>
</ThreatL3>
<Agents>
Alcohol foam, dry chemical, carbon dioxide
</Agents>
<Precaution>
<ol>
<li>Withdraw immediately in case of rising sound from venting safety device or any discolouration of tank due to fire.</li>
<li>Isolate and remove discharged material.</li>
<li>Unstable, avoid exposure to alkalis, strong acids, oxygen, elevated temperatures</li>
</ol>
</Precaution>
<Safe_Distance>
<small>
<Isolate>
150
</Isolate>
<Protect>
1400, 4000
</Protect>
</small>
<large>
<Isolate>
800
</Isolate>
<Protect>
9300, 11000
</Protect>
</large>
</Safe_Distance>
</Fire>
<NonFire>
<ol>
<li>AVOID CONTACT WITH LIQUID AND VAPOR. KEEP PEOPLE AWAY.</li>
<li>AVOID INHALATION</li>
</ol>
<Precaution>
<ol>
<li>Shut off ignition sources.</li>
<li>Unstable, avoid exposure to alkalis, strong acids, oxygen, elevated temperatures</li>
<li>Isolate and remove discharged material.</li>
</ol>
</Precaution>
</NonFire>
<Public_Safety>
<ol>
<li>Evacuate area in case of large discharge.</li>
<li>Notify local health and pollution control agencies.</li>
<li>Protect water intakes</li>
</ol>
</Public_Safety>
</Response>
<PPE>
<material>
<ol>
<li>Butyl Rubber (0.6-0.7mm)</li>
</ol>
</material>
<IDLH>
<Cat>1(EU), A(US)</Cat>
<APF>1000</APF>
<Body>
Fully encapsulating, vapor protective clothing should be worn to deal with spills or leaks with no fire.
Fire Fighters should wear additional protection for heat.
</Body>
<Respirator>
Any supplied-air respirator that has a full facepiece and is operated in a pressure-demand or other positive-pressure mode.
Carry an auxiliary self-contained positive-pressure breathing apparatus.
</Respirator>
</IDLH>
<STEL>
<Cat>1-3(EU) A-C(US)</Cat>
<Body>
The concentrations are low but the tanks/containers with Acrolein can explode in fire releasing more into the air.
As a precaution it is advisable to wear PPE level 1.
Fire Fighters should wear additional protection for heat.
</Body>
<Respirator>
Any air-purifying, full-facepiece respirator (gas mask) with a chin-style, front- or back-mounted organic vapor canister.
Any self-contained breathing apparatus with a full facepiece.
Any chemical cartridge respirator with a full facepiece and organic vapor cartridge(s).
</Respirator>
</STEL>
</PPE>
<Health>
<Inhalation>
<low>
<ol>
<li>irritation of nose and throat</li>
<li>a feeling of pressure in the chest</li>
<li>shortness of breath with nausea and vomiting</li>
</ol>
</low>
<high>
<ol>
<li>Loss of consciousness</li>
<li>Congestion in the chest</li>
<li>Bluish skin colour</li>
<li>Asthma</li>
<li>Lung Damage with fluid collecting in the lung</li>
</ol>
</high>
<First_Aid>
<ol>
<li>Move victims to fresh air. Emergency personnel should avoid self-exposure to acrolein.</li>
<li>Evaluate vital signs including pulse and respiratory rate, and note any trauma. If no pulse is detected, provide CPR.</li>
<li>If not breathing, provide artificial respiration. If breathing is labored, administer oxygen or other respiratory support.</li>
<li>Obtain authorization and/or further instructions from the local hospital for administration of an antidote or performance of other invasive procedures.</li>
<li>RUSH to a health care facility.</li>
</ol>
</First_Aid>
</Inhalation>
<Skin>
<low>
<ol>
<li>Irritation</li>
<li>Redness</li>
</ol>
</low>
<high>
<ol>
<li>Contact dermatitis</li>
<li>Blistering</li>
<li>Severe tissue damage</li>
<li>Can be carcinogenic: Not enough evidence found</li>
</ol>
</high>
<First_Aid>
<ol>
<li>Move victims to fresh air. Emergency personnel should avoid self-exposure to acrolein.</li>
<li>Flush at once with large volumes of water.</li>
<li>If skin is in tact wash thoroughly with soap and large quantities of running water, otherwise with water only</li>
<li>Obtain authorization and/or further instructions from the local hospital for administration of an antidote or performance of other invasive procedures.</li>
<li>RUSH to a health care facility.</li>
</ol>
</First_Aid>
</Skin>
<Eyes>
<low>
<ol>
<li>Mild to severe irritation in eyes</li>
<li>Tissue damage</li>
<li>redness, weeping, and swelling of lids</li>
</ol>
</low>
<high>
<ol>
<li>Tissue damage, corrosion, even blindness</li>
<li>redness, weeping, and swelling of lids</li>
</ol>
</high>
<First_Aid>
<ol>
<li>Move victims to fresh air. Emergency personnel should avoid self-exposure to acrolein.</li>
<li>Evaluate vital signs including pulse and respiratory rate, and note any trauma. If no pulse is detected, provide CPR.</li>
<li>Immediately but gently flush the eyes with large amounts of water for at least 15 min, occasionally lifting the upper and lower eyelids.</li>
<li>RUSH to a health care facility.</li>
</ol>
</First_Aid>
</Eyes>
<Ingestion>
<low>
<ol>
<li>Irritation, burning sensation in mouth and stomach</li>
</ol>
</low>
<high>
<ol>
<li>Loss of consciousness</li>
<li>Severe corrosion and tissue damage</li>
<li>Bluish skin colour</li>
<li>Asthma</li>
<li>Lung Damage with fluid collecting in the lung</li>
</ol>
</high>
<First_Aid>
<ol>
<li>Evaluate vital signs including pulse and respiratory rate, and note any trauma. If no pulse is detected, provide CPR.</li>
<li>Have the victim rinse the contaminated mouth cavity several times with a fluid such as water.</li>
<li>Immediately after rinsing, have the victim drink one cup (8 oz) of fluid and no more. More amount can create enough pressure to perforate already damaged tissues</li>
<li>Do not permit the victim to drink milk or carbonated beverages</li>
<li>Do not permit the victim to drink any fluid if more than 60 min have passed since initial ingestion.</li>
<li>RUSH to a health care facility.</li>
</ol>
</First_Aid>
</Ingestion>
</Health>
</Acrolein>

one of the resulting files can look something like:


<?xml version="1.0" encoding="utf-8" ?>
<Content>
<Hazard>Chemical</Hazard>
<name>Acrolein</name>
<ThreatLevel>2</ThreatLevel>
<Coordinates>(13.38373, 47.77728, 479)</Coordinates>
<Precaution>
<ol>
<li>As an immediate precautionary measure, isolate spill or leak area for at least 100 meters (330 feet) in all directions.</li>
<li>Withdraw immediately in case of rising sound from venting safety device or any discolouration of tank due to fire.</li>
<li>Isolate and remove discharged material.</li>
<li>Combat fires from safe distance or protected location preferably upwind.</li>
</ol>
</Precaution>


</Content>

BukhtiarM
18 Aug 2014, 11:31 PM
Hellooooooo,

Do you guys think i should write something on the server side for instance in PHP? or is it easily possible using ext data readers and writers? Please reply... Any sorta help would be appreciated.