Solved

XML creation

Posted on 2012-03-14
3
512 Views
Last Modified: 2012-06-27
Hi, how do I create the following xml file in c sharp code:

<?xml version="1.0" encoding="utf-16" ?>
<ci:CommandInstruction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://navtechradar.com/ICDNAV001-StatusReport ICDNAV001-CommandInstruction.xsd"
xmlns:ci="http://www.navtechradar.com/ICDNAV001-CommandInstruction"
xmlns:cmn="http://www.navtechradar.com/ICDNAV001-CommonTypes">
<!-- Note that the sender element is not optional in command instructions - the subscriber must include it -->
<ci:Sender SenderId ="XFSControlSuite:1" NetworkAddress="192.168.24.5" NetworkPort ="2077"/>
<!-- Command ID:4 is a request for a status report -->
<ci:Command Sent="2010-04-03T22:01:02.112" CommandId="4" />
</ci:CommandInstruction>
0
Comment
Question by:DamoD0
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 29

Assisted Solution

by:QPR
QPR earned 100 total points
ID: 37723588
0
 

Author Comment

by:DamoD0
ID: 37723596
The specific problem I have is how to add the <ci:CommandInstruction/> root element. The exception tells me I can't use ":".

I'm using XmlDocument so I'm sure there's just one method to do this.

Thanks.
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 400 total points
ID: 37723847
Use LINQ To XML, perffered way to create/edit xml files...
Its much much easier and developer friendly syntax

Here is an example:-
http://msdn.microsoft.com/en-us/library/bb308960.aspx
http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/creating-and-saving-xml-tree-using-linq-to-xml/
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question