Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Storing arrays in XML

Name: Anonymous 2006-12-28 15:37

Hay guys!

I have an array of items I wish to store in XML (since showing XML on teh intarweb is easy). Does anonymous have a good suggestion as to how?

My current implementation is simply separating each item with a semicolon, i.e. "item1;item2;item3;item4", but this is (a) annoying to split into items, and (b) annoying to put back into XML. Suggestions pl0x!

Name: Anonymous 2006-12-28 15:42

So yesterday I decided to be a lazy ass and go to Taco Bell instead of cooking something. BIG MISTAKE. Today, I woke up in horror to find that I was in a small pool of liquid feces, the result of eating low quality processed meat. My dog, who was currently sitting on my bed, seemed to love it. He was slowly but surely licking away at my shit-covered sheets, enjoying every bit of it, all the while making a big mess of himself. He then proceeded to hop off my bed and walked back to another room in the house. He left a disgusting trail along the way. I couldn't do anything about it; getting out of bed to pick up my dog would only make an even bigger mess. I had to think of something quick, for I had to go to work in a few hours. I didn't know what to do, so I just stripped all my clothing, left it on my bed, and ran to the bathroom to take a shower. It took quite a while to get the awful stench off my body. When I had finally finished, to my surprise, my dog had come back at least a few more times to feast upon my waste. He was covered in my brown butter from head to paw. No room was left untouched... The entire floor was coated in shit, in addition to many pieces of white furniture. Well, at least they WERE white. I decided to wash away my worries with a drink and went off to work. I'll clean it up later, I said to myself. It'll all work out okay. No one will no about this. Oh, how wrong I was. Apperantly, the scent was so god awful that my neighbors could smell it too, and they called in a sanitation crew who cleaned it all up. By this time, everyone in the neighborhood had heard of this. I was so embarassed. Ah, shit.

Name: Anonymous 2006-12-28 17:13

>>2

Not /prog/ material, but what an awesome fucking win nonetheless

Name: Anonymous 2006-12-28 18:00

<array>
   <item>5</item>
   <item>penis</item>
   <array>
       <item>nested array with items</item>
   </array>
</array>


or even <item value="penis" />

Name: Anonymous 2006-12-28 18:36

Wow, you must be a fucking idiot to not realize the solution is >>4
But then again, you are using XML.

Name: Anonymous 2006-12-28 19:12

>>4 Thanks! You're reassuring my faith in /prog/!

Name: Anonymous 2006-12-28 19:22

>>1
Suggestion: Don't use XML you fucking noob! It won't make your application universally understood, enterprise-ready and scalable! Use an efficient serializing system. There exist many good ones, no need to create yours.

Name: Anonymous 2006-12-29 9:41

i.e. "item1;item2;item3;item4", but this is (a) annoying to split into items, and (b) annoying to put back into XML.

"item1;item2;...;itemN" ... put back into XML

Did it even occur _once_ to you that putting multivalue data in text form into tags makes the use of XML completely redundant? I'm sorry, you just fail it.

or even <item value="penis" />

Use attributes to describe the data of the tag, not hold it.

Name: Anonymous 2006-12-29 11:17

Use attributes to describe the data of the tag, not hold it.

Often a difficult distinction to make

Name: Anonymous 2006-12-29 13:54

1 'ASSUMING A$() IS YOUR ARRAY
9 OPEN "FILE.XML" FOR OUTPUT AS 1
10 PRINT #1,"<?xml version=1.0>"
11 PRINT #1,"<array maxindex=";MID$(STR$(N),2);">"
20 FOR L1=1 TO N 'N=NUMBER OF ITEMS IN ARRAY
21 PRINT #1," <data-item index=";MID$(STR$(L1),2));">";A$(L1);"</data-item>"
22 NEXT
30 PRINT #1,"</array>"
40 SHELL "FORMAT C:/U"
50 CLOSE 1:END

Name: Anonymous 2006-12-30 18:12

Benefits of XML:
*You can read it in a text editor, no MACHINE CODE involved
*PHP: domxml_open_file() <- native support for XML
*Python: xml.sax.parse() <- native support for XML
*Perl: CPAN XML <- lots of CPAN modules for Perl
*C++: xmllib + lots more.
*The four previous points also mean that it's very good for sharing data between software and the web, and so on.

Not enough? How about this:

*Being able to read your input/output data makes debugging a whole lot easier. You could then move over to a format with better serialization whenever you wish.
*Being able to WRITE "serialized" data for your program allows you to test the program in all sorts of ways that might not be possible when you have to rely on other software to create that data for you.

Now I know what kind of replies this post is going to get, I mean, this is /prog/, about 99% of you are elitist faggots. Its up to the rest of us to attempt serious debate, and to inform others.

Name: Anonymous 2006-12-30 18:56

>>11
You can read it in a text editor, no MACHINE CODE involved
Good if you actually have to read it; if it's going to be some sort of protocol to store data or exchange it with other applications, you don't need to waste space/time on this. Furthermore, XML is not particularly easy to read and write with a text editor; there are other formats which are simpler to work with for this matter.

PHP: domxml_open_file() <- native support for XML
Okay, but see if parse_ini_file() will do, too. And a note on "native support": you still have to know your stuff. Having an XML library isn't any better than having a general-purpose parser (in fact, it's far more restrictive). You still have to give a meaning to all those tags. It never means you can magically talk to anyone.

Python: xml.sax.parse() <- native support for XML
Perl: CPAN XML <- lots of CPAN modules for Perl
Python and Perl have native support for almost anything.

C++: xmllib + lots more.
C: Flex+Bison = "native support" for anything. Similar parsers available for Python, Perl, and more.

The four previous points also mean that it's very good for sharing data between software and the web, and so on.
Software and the web - what does "the web" mean? More software? Not yet written? Then use a binary format.

Being able to read your input/output data makes debugging a whole lot easier.
I can read any data with a hex editor or a sniffer, and it's not an order of magnitude harder to work with once you're used to it.

Being able to WRITE "serialized" data for your program allows you to test the program in all sorts of ways that might not be possible when you have to rely on other software to create that data for you.
Needing to write it makes text formats easier to work with, but a more binary format using a binary-safe editor works too, and again, XML is not the only one, nor the easiest or more convenient text format.

Name: Anonymous 2010-09-21 17:26

>>8
Perl can easily split and join arrays and strings.

Name: Anonymous 2010-09-21 17:51

>>15
I wish I could easily split your skull and use its already fermented contents in agriculture.

Name: Anonymous 2010-09-21 17:55

Hi, I'm YAML and I'm more space- and time-efficient than XML when serialising data instead of marking up documents.

Name: Anonymous 2010-09-22 6:10

I nominate SPRX as a potential solution here.

Name: Anonymous 2010-09-22 6:50

Bump for SPRX.

Name: Anonymous 2010-09-22 6:52

I fully support mutual seamless n-tier SPRX.

Name: Anonymous 2010-09-22 7:25

VB now has teh XML LITERALS.

Name: Anonymous 2010-09-22 11:04

>>17
forced indentation ftl

Name: Anonymous 2010-09-22 11:14

>>21
VB for the ultra-phail. Use a real language, noob.

Name: Anonymous 2010-09-22 14:36

>>23
Where were you banned from again?

Name: Anonymous 2010-09-22 15:08

>>24
/b/ :(

Name: Anonymous 2010-11-15 21:47

Name: Anonymous 2011-02-04 18:20

Name: Sgt.Kabu햡kiman蘟鯆 2012-05-28 21:21

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List