|
-
Jul 9th, 2004, 12:12 PM
#1
Thread Starter
yay gay
how to write a xml file with the following format?
<?xml version="1.0" encoding="windows-1252" standalone="yes"?>
<DCPlusPlus>
<Settings>
<Connection type="string">Cable</Connection>
<DownloadDirectory type="string">G:\DOWNLOADS\DC++\</DownloadDirectory>
<Nick type="string">Iniquity</Nick>
</Settings>
<Share>
<Directory>G:\metal albuns</Directory>
<Directory>G:\mp3</Directory>
</Share>
</DCPlusPlus>
How can I do it? With which classes?
\m/  \m/
-
Jul 9th, 2004, 03:17 PM
#2
I wonder how many charact
-
Jul 9th, 2004, 06:02 PM
#3
PowerPoster
Something cool you can do is to build a xsd (schema) of that xml. Then you can use the xsd.exe tool to generate classes based off the schema and you then have a class that you can fill the properties of, then serialize to that xml. I just discovered the xsd.exe tool, and I am falling in love with it. I can do so much with it now that I am finding uses everywhere.
-
Jul 9th, 2004, 10:21 PM
#4
I wonder how many charact
Don't get drunk with the stuff man... the hangover might kill ya 
Take it slow...
-
Jul 10th, 2004, 07:47 AM
#5
Thread Starter
yay gay
what does this mean?
w.WriteAttributeString("xmlns", "x", null, "urn:1");
\m/  \m/
-
Jul 10th, 2004, 10:01 AM
#6
I wonder how many charact
You don't have to use that many arguments... there are 2 other overloaded functions... one of them takes two parameters: the name of attribute and its value.
But for the method as you requested it:
http://msdn.microsoft.com/library/de...ringtopic3.asp
"xmlns"
prefix
The namespace prefix of the attribute.
"x"
localName
The local name of the attribute.
null
ns
The namespace URI of the attribute.
"urn:1"
value
The value of the attribute.
Basically, the localname gets appended to any elements you write using StartElement(see note below)... so if the namespace is "x", when you write an element called "Beer" with a value of "2", the XMLWriter will automatically append "x" in front of "Beer", giving you:
<x:Beer>2</x:Beer>
Note: But, you could also do that using an overloaded function of StartElement... its really a horse a piece..
Last edited by nemaroller; Jul 10th, 2004 at 10:09 AM.
-
Jul 10th, 2004, 05:05 PM
#7
PowerPoster
Originally posted by nemaroller
Don't get drunk with the stuff man... the hangover might kill ya 
Take it slow...
It isn't that bad, but I had one of those light bulb moments with it, and the mind started racing with what can be done.
-
Jul 11th, 2004, 08:53 AM
#8
Thread Starter
yay gay
ok after some coding i got this:
<leechServerROOT>
<FTP d2p1:Name="" xmlns:d2p1="[Insomnium's Palace]" />
</leechServerROOT>
I'd like to have:
<FTP Name="[Insomnium's Palace]" />
To write the attribute i'm using:
Code:
xtw.WriteStartAttribute("Name", "Insomniums Palace")
Is it even possible at all?
\m/  \m/
-
Jul 11th, 2004, 09:07 AM
#9
Thread Starter
yay gay
Another question, if I have the following:
<ROOT>
<FTP>
<NAME>lol</NAME>
</FTP>
<FTP>
<SIZE>15</SIZE>
</FTP>
</ROOT>
Will this raise any kind of error when reading it?
Or will it read it up as if both "properties" Name and Size were right next to each other?
\m/  \m/
-
Jul 11th, 2004, 01:00 PM
#10
I wonder how many charact
As a last resort, you can use the WriteRaw method.... since I haven't used the class since last year... I don't remember all its pecularities...
As far as your second post... they will be interpreted as seperate entities... one without a name attribute, one without a size attribute.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|