?
Solved

XML parsing and removing

Posted on 2008-10-06
2
Medium Priority
?
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
Ivo Stoykov earned 2000 total points
ID: 22650819
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
ID: 22678355
Thanks, that worked! I'm sorry it took me so long to get back to you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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