Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# 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 at 2-Oct-12 7:40am
   
What have you tried so far? Where are you stuck?
Adersh Ram at 2-Oct-12 7:40am
   
Creating the fist name spaces (second and third line )
Sandeep Mewara at 2-Oct-12 7:49am
   
If they are known and fixed. Hard code it before forming the body of XML.
Adersh Ram at 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 at 2-Oct-12 7:54am
   
Then based on condition hardcode it. I don't think there is any other way.
 
Adersh Ram at 2-Oct-12 7:57am
   
ok, thanks for your quick reply.
Sergey Alexandrovich Kryukov at 2-Oct-12 12:49pm
   
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.  
  3. 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[^].
  4.  
  5. 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 at 2-Oct-12 13:11pm
   
Good enough. My 5!
Sergey Alexandrovich Kryukov at 2-Oct-12 13:13pm
   
Thank you, Sandeep.
--SA
Maciej Los at 2-Oct-12 14:52pm
   
Agree, my 5 too!
Sergey Alexandrovich Kryukov at 2-Oct-12 15:23pm
   
Thank you, Maciej.
--SA
Adersh Ram at 2-Oct-12 15:17pm
   
Thanks SA
 
It is really helpfull, sorry for late reply....!
Sergey Alexandrovich Kryukov at 2-Oct-12 15:24pm
   
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
0 OriginalGriff 278
1 Sergey Alexandrovich Kryukov 236
2 PhilLenoir 179
3 ChauhanAjay 166
4 ClimerChinna 150
0 Sergey Alexandrovich Kryukov 6,140
1 OriginalGriff 5,195
2 CPallini 2,473
3 Richard MacCutchan 1,607
4 Abhinav S 1,505


Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2014
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