尝试使用DOM解析我的xml文件时遇到问题。问题在于我处理的xml文件的结构,因为它在它的标签之前有破折号所以我要求它如何在xml文件的每个标签之前删除所有的破折号和空格...谢谢你的帮助 这里是我处理的xml文件的一个例子:
< ?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>
答案 0 :(得分:1)
简单替换所有“ - &lt;”用“&lt;”在notepad ++中,对于当前目录中的所有XML文件或通过java中的代码,将解决此问题。您可能还想将所有“&lt;”替换为“&lt;”,并且当您从中创建DOM时它将正常编译。 话虽如此,最好找到问题的根源。