Click here to Skip to main content
12,448,164 members (52,967 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# VB VB.NET
Hi Folks,

I want to create a Xml file Like
<?xml version="1.0" encoding="UTF-8"?>
<NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"/>
  </Header>
  <PortletQuery>
    <Filter name="code" criteria="EQUALS">xogHelloWorld</Filter>
  </PortletQuery>
</NikuDataBus>

Please Help me !

Thanks,
Adersh Ram BK
Posted 2-Oct-12 1:28am
Comments
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.
--SA

1 solution

Rate this: bad
 
good
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.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].

  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.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].

  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].

Also, I'm not sure that you really need to write/read XML directly. Chances are, you need to use Serialization:
http://en.wikipedia.org/wiki/Serialization#.NET_Framework[^],
http://msdn.microsoft.com/en-us/library/7ay27kt9%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/ms233843.aspx[^].

Nearly the most comprehensive and easy-to-use method of serialization is the one based on Data Contract:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

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,
—SA
  Permalink  
Comments
Sandeep Mewara 2-Oct-12 13:11pm
   
Good enough. My 5!
   
Thank you, Sandeep.
--SA
Maciej Los 2-Oct-12 14:52pm
   
Agree, my 5 too!
   
Thank you, Maciej.
--SA
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.
--SA

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.160811.3 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2016
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