Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1039041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:03:02+00:00 2026-05-16T15:03:02+00:00

I got an Xml file fileOri.xml and there are some lines like <SubItem name=’somename’

  • 0

I got an Xml file fileOri.xml and there are some lines like

<SubItem name='somename' value='someVal'></SubItem>

and I plan to copy these lines to another file fileDes.xml. Is there a rapidly & easily way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:03:03+00:00Added an answer on May 16, 2026 at 3:03 pm

    Adding to Rajs answer, here’s how you can do it using Transform:

    The code

    XmlTextReader reader = new XmlTextReader("C:\\fileOri.xml");
    XmlTextWriter writer = new XmlTextWriter("C:\\fileDes.xml", Encoding.UTF8);
    XslCompiledTransform transform = new XslCompiledTransform();
    transform.Load("C:\\MyStylesheet.xslt");
    transform.Transform(reader, writer);
    

    The Stylesheet

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/">
            <!-- define the root element for your destination document -->
            <xsl:element name="root">
                <xsl:apply-templates />
            </xsl:element>
        </xsl:template>
    
        <xsl:template match="//SubItem">
            <xsl:copy-of select="." />
        </xsl:template>
    
    </xsl:stylesheet>
    

    Doing it via Transformation gives you the flexibility to change the content you like to copy without touching the executable in the future – just modify the Xslt to your needs.


    Hint

    Your question suggests that you probably rather want a flat text file with line items for further processing – in that case you can still use Xslt but with text output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got an xml file containing some attributes like <string name=my/ attribute optional=true>
lets say i got some xml file which looks like this: <NewDataSet> <Table1 id
I've got an XML file that looks like this: ... <body> <unit id=1 name
I got a string from parsing a XML file which looks like this: Fri,
I've got some routines in an XSLT stylesheet that process an XML file to
I've got an xml file that looks like this: <Records> <Record> <table> <Row> <col1>value1</col1>
I got the following XML file (Data.xml): <root> <sitecollection name=1A> <site name=1B> <maingroup name=1C>
I've got an XML doc to deal with that contains attributes like: <action name=foo
I've got an XML config file with some really long strings. Generally, I format
I've got an xml file with the following: <content_item> <primary_keys> <primary_key> <source>firstone</source> <value>123</value> </primary_key>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.