Topic: new to xml Pages that link to <a href="https://ozoneasylum.com/backlink?for=11127" title="Pages that link to Topic: new to xml" rel="nofollow" >Topic: new to xml\

 
Author Thread
ninmonkey
Nervous Wreck (II) Inmate

From:
Insane since: Nov 2003

IP logged posted posted 01-07-2004 01:01 Edit Quote

I decided to make a perl script using xml to store the data for bookmarks (see this thread ) I haven't used xml before, and thought now is a good time to learn. I created an xml file, and it doesn't have any errors when veiwing, so:

1) Did I write it correctly?

2) Do I need a <bookmarkentry></bookmarkentry> to surround the xml I wrote? (a seperate tag from
menuitem )

3)Should/do I need to write a DTD?

code:
example bookmark directory structure:
/bookmarks
/programming
/cpp
link1
link2
/tut
tut link1
tut link2
/perl
p link1
p link2
link just in programming

code:
xml of the above sample:
<?xml version="1.0" encoding="ISO-8859-1"?>
<menuitem title="programming">
<menuitem title="cpp">
<link url="#">link1</link>
<link url="#">link2</link>
<menuitem title="tut">
<link url="#">tut link1</link>
<link url="#">tut link2</link>
</menuitem>
</menuitem>
<menuitem title="perl">
<link url="#">p link1</link>
<link url="#">p link2</link>
</menuitem>
<link url="#">general programming</link>
</menuitem>

thank you,
--monkey

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

IP logged posted posted 01-07-2004 03:54 Edit Quote

i think the two different items called "menuitem title" may lend itself to some trouble.

Later,

C:\


~Binary is best~

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

IP logged posted posted 01-07-2004 11:44 Edit Quote
quote:
1) Did I write it correctly?


Define "correctly".
It's well-formed, yes.

quote:
2) Do I need a <bookmarkentry></bookmarkentry> to surround the xml I wrote? (a seperate tag from
menuitem )


No, it's not needed but it would be a little more logical to have a different name for the root element.
If I would do a bookmark XML file I would probably have something like the following structure

code:
<bookmarks>
<dir>programming
<dir>cpp
<bookmark href="">link 1</bookmark>
<bookmark href="">link 2</bookmark>
</dir>
<dir>tut
<bookmark href="">link 1</bookmark>
<bookmark href="">link 2</bookmark>
</dir>
</dir>
<dir>perl
<bookmark href="">link 1</bookmark>
<bookmark href="">link 2</bookmark>
</dir>
<bookmark href="">link just in programming</bookmark>
</bookmarks>


(Notice that I didn't put too much thought in that, and maybe some things should be changed. Maybe the directory name should be inside an element too.)

quote:
3)Should/do I need to write a DTD?


Shouldn't be needed. It's up to you, if you want to check if your document validates.
On the other hand, it shouldn't be that hard.

[This message has been edited by HZR (edited 01-07-2004).]

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

IP logged posted posted 01-07-2004 14:57 Edit Quote

HZR: I'm a little rusty at XSLT and XML parsing, but wouldnt your structure return cpplink 1link 2 as value-of the bookmarks[1]/dir[1]/dir[1] XPATH ?

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

IP logged posted posted 01-07-2004 15:06 Edit Quote

That is probably true poi, and I'm rustier than you
So, putting the dir name in an element is probably a good idea (I wouldn't do something like <dir title="cpp"> ).

ninmonkey
Nervous Wreck (II) Inmate

From:
Insane since: Nov 2003

IP logged posted posted 01-07-2004 17:47 Edit Quote

Is there something wrong with the word "title"? If I understand this is wrong:

code:
<menuitem title="cpp">

and this is right:

code:
<menuitem name="cpp">



HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

IP logged posted posted 01-07-2004 18:00 Edit Quote

No, the reason I wouldn't use title="cpp", is that "cpp" should be part of the content IMO.



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu