Click here to Skip to main content
15,886,077 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Folks,

I want to create a Xml file Like
XML
<?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
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.


1 solution

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
 
Share this answer
 
Comments
Sandeep Mewara 2-Oct-12 13:11pm    
Good enough. My 5!
Sergey Alexandrovich Kryukov 2-Oct-12 13:13pm    
Thank you, Sandeep.
--SA
Maciej Los 2-Oct-12 14:52pm    
Agree, my 5 too!
Sergey Alexandrovich Kryukov 2-Oct-12 15:23pm    
Thank you, Maciej.
--SA
Adersh Ram 2-Oct-12 15:17pm    
Thanks SA

It is really helpfull, sorry for late reply....!

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900