Hen
Hen

Reputation: 253

how to make xml file readable by DOM?

I face problems while trying to parse my xml files using DOM. The problem is in the structure of the xml files that I deal with because it has have dashes before its tags so what I am asking for its how to delete all the dashes and spaces before every tag I the xml file..thanks for help here an example of the xml file that I deal with:

  < ?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?> 

- < HWData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="hw_data.xsd">

< Header xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" AdaptationName="NWI3BulkUpload" AccessProtocol="NWI3" time="2013-05-29T13:39:34" uploaded="true" version="1.0" /> 

- < NE xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" vendorName="Nokia Siemens Networks" objectClass="NE" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031" NEId="PLMN-PLMN/RNC-6/WBTS-4031" NEType="WBTS" operationalState="enabled" locationName="GAB4031" nameFromPlanningSystem="" systemTitle="Nokia Flexi WCDMA Base Station">

- < EQHO vendorName="Nokia Siemens Networks" objectClass="EQHO" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-173" equipmentHolderId="173" equipmentHolderType="Subrack" equipmentHolderSpecificType="471469A-173" identificationCode="471469A" version="" serialNumber="L6103725271" userLabel="FSME" state="working">

< UNIT vendorName="N" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-173/UNIT-16" unitId="16" unitTypeActual="CORE_FSME" identificationCode="083833A" version="104" serialNumber="L6103725271" /> 

< UNIT vendorName="NOKIA SIEMENS NETWORKS" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-173/UNIT-225" unitId="225" unitTypeActual="FTLB" identificationCode="471984A" version="103" serialNumber="RY111112346" /> 
  < /EQHO>
- < EQHO vendorName="NSN" objectClass="EQHO" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192" equipmentHolderId="40192" equipmentHolderType="Subrack" equipmentHolderSpecificType="472083A-40192" identificationCode="472083A" version="203" serialNumber="K9123521310" userLabel="FXDA" state="working">

 < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40266" unitId="40266" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496511644" /> 

 < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40267" unitId="40267" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496511642" /> 

< UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40268" unitId="40268" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496511641" /> 

< UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40269" unitId="40269" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496511643" /> 

< UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40282" unitId="40282" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496411404" /> 

< UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40284" unitId="40284" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496411401" /> 

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40298" unitId="40298" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496611944" /> 

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40300" unitId="40300" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496611941" /> 

  < /EQHO>

- < EQHO vendorName="NSN" objectClass="EQHO" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192" equipmentHolderId="40192" equipmentHolderType="Subrack" equipmentHolderSpecificType="472083A-40192" identificationCode="472083A" version="203" serialNumber="K9123521310" userLabel="FXDA" state="working">

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40266" unitId="40266" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496511644" /> 

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40267" unitId="40267" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496511642" /> 

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40268" unitId="40268" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496511641" /> 

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40269" unitId="40269" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496511643" /> 
  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40282" unitId="40282" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496411404" /> 

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40283" unitId="40283" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496411402" /> 

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40284" unitId="40284" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496411401" /> 

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40285" unitId="40285" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496411403" /> 

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40298" unitId="40298" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496611944" /> 

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40299" unitId="40299" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496611942" /> 

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40300" unitId="40300" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496611941" /> 

  < UNIT vendorName="AR" objectClass="UNIT" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40192/UNIT-40301" unitId="40301" unitTypeActual="TILT" identificationCode="CV3PX310R-BTQ" version="" serialNumber="00000008496611943" /> 

  < /EQHO>

  < EQHO vendorName="Nokia Siemens Networks" objectClass="EQHO" objectClassVersion="1" MOID="NE-RNC-6/DN:NE-WBTS-4031/EQHO-40448" equipmentHolderId="40448" equipmentHolderType="Subrack" equipmentHolderSpecificType="472100A-40448" identificationCode="472100A" version="101" serialNumber="K9123314694" userLabel="FRGP" state="working" /> 

  < /NE>

  < /HWData>

Upvotes: 1

Views: 116

Answers (1)

stackMan10
stackMan10

Reputation: 742

A simple replace all "- <" with "<" in notepad++ for all XML files in your current directory or through code in java will fix this. You may also want to replace all "< " with "<", and it will compile fine when you create a DOM out of it. Having said that, it would be better to get to the root of the problem.

Upvotes: 1

Related Questions