Click here to Skip to main content
12,997,038 members (131,765 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi Folks,

I want to create a Xml file Like
<?xml version="1.0" encoding="UTF-8"?>
<NikuDataBus xmlns:xsi="" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_read.xsd">
  <Header version="8.0" action="read" objectType="contentPack" externalSource="NIKU">
    <!-- you change the order by simply swap 1 and 2 number in the name attribute -->
    <args name="order_by_1" value="code"/>
    <args name="documentLocation" value="C:\niku"/>
    <Filter name="code" criteria="EQUALS">xogHelloWorld</Filter>

Please Help me !

Adersh Ram BK
Posted 2-Oct-12 1:28am
Sandeep Mewara 2-Oct-12 7:40am
What have you tried so far? Where are you stuck?
Adersh Ram 2-Oct-12 7:40am
Creating the fist name spaces (second and third line )
Sandeep Mewara 2-Oct-12 7:49am
If they are known and fixed. Hard code it before forming the body of XML.
Adersh Ram 2-Oct-12 7:51am
sometimes it will change some condition, so it cannot hard code that....
Is there any way to do that
Sandeep Mewara 2-Oct-12 7:54am
Then based on condition hardcode it. I don't think there is any other way.

Adersh Ram 2-Oct-12 7:57am
ok, thanks for your quick reply.
Could be done via serialization. Anyway, I provided a short overview of nearly all approaches available in .NET, please see my answer.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

This is my short overview of what you already have from .NET:

  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.

  2. Use the classes System.Xml.XmlTextWriter and System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.

  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.

Also, I'm not sure that you really need to write/read XML directly. Chances are, you need to use Serialization:[^],[^],[^].

Nearly the most comprehensive and easy-to-use method of serialization is the one based on Data Contract:[^].

Please also see my past answers where I advocate this approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].

Good luck,
Sandeep Mewara 2-Oct-12 13:11pm
Good enough. My 5!
Thank you, Sandeep.
Maciej Los 2-Oct-12 14:52pm
Agree, my 5 too!
Thank you, Maciej.
Adersh Ram 2-Oct-12 15:17pm
Thanks SA

It is really helpfull, sorry for late reply....!
You are welcome.
Late reply is not a problem at all; I get all notifications.

So, are you going to accept the answer formally (green button)? -- thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100