Solved

XML parsing and removing

Posted on 2008-10-06
2
348 Views
Last Modified: 2013-12-17
I need to remove some lines from some XML files, specifically some of the xmlns stuff, but I need to do it in batches of thousands of files.

I'm trying to write a program that will ream the folder and remove the xmlsn:addData and xmlns:form from each file that looks like this... I'm not very adept with XML, so I'm having a rough time understanding what each of these elements are. Any ideas?

I'm using C# as my coding language.
<document xmlns="http://www.ademero.com/XmlSchemas/ContentCentral/XmlCaptureDescriptorV1.1" 

		  xmlns:addData="http://www.abbyy.com/FlexiCapture/Schemas/Export/AdditionalFormData.xsd" 

		  xmlns:form="http://www.abbyy.com/FlexiCapture/Schemas/Export/FormData.xsd">

	<imageFiles>

		<file>Images\AIRCO-V9516NT_1.pdf</file>

	</imageFiles>

	<destination>

		<catalog docType="default">Accounts Payable</catalog>

	</destination>

	<fields>

		<field name="Invoice">V9516NT</field>

		<field name="Vendor">AIRCO INC</field>

		<field name="Date">1999-04-14</field>

	</fields>

</document>

Open in new window

0
Comment
Question by:developernetwork
2 Comments
 
LVL 22

Accepted Solution

by:
Ivo Stoykov earned 500 total points
Comment Utility
Hello developernetwork
Please try the code below
HTH
I

    private void test()

    {

      String s = "<document xmlns=\"http://www.ademero.com/XmlSchemas/ContentCentral/XmlCaptureDescriptorV1.1\" xmlns:addData=\"http://www.abbyy.com/FlexiCapture/Schemas/Export/AdditionalFormData.xsd\" xmlns:form=\"http://www.abbyy.com/FlexiCapture/Schemas/Export/FormData.xsd\"> <imageFiles> <file>Images\\AIRCO-V9516NT_1.pdf</file> </imageFiles> <destination> <catalog docType=\"default\">Accounts Payable</catalog> </destination> <fields> <field name=\"Invoice\">V9516NT</field> <field name=\"Vendor\">AIRCO INC</field> <field name=\"Date\">1999-04-14</field> </fields></document>";

      XmlDocument x = new XmlDocument();

      x.LoadXml(s);

      ((XmlElement)x.DocumentElement).RemoveAttribute("xmlns:addData");

      ((XmlElement)x.DocumentElement).RemoveAttribute("xmlns:form");

      Debug.WriteLine(x.OuterXml);

    }

Open in new window

0
 

Author Comment

by:developernetwork
Comment Utility
Thanks, that worked! I'm sorry it took me so long to get back to you.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now