Access to the XML pages, info inside...

O

old.Yomar

Guest
Our version, which still needs a lot of improvement, but is the only version written in VBScript (so that it can be used on ALL servers).

Includes simple bubble sort. Didn't get QuickSort to work.

http://www.akebono.cistron.nl
 
T

Thorarin

Guest
Yomar;
Your version does not seem to work at all over here, because browser security settings don't allow the CreateObject on remote pages.

As for your question:
You should use the childNodes() thing so much. Instead you should use selectSingleNode() and selectNodes(). Your main loop for example:

Code:
dim characters
dim character
set characters = xmlDoc.documentElement.childNodes(0).selectNodes("character")

For x = 0 To characters.length - 1
    set character = characters.nextNode()

    ' ...

    getrace(x)=character.selectSingleNode("race").text
    getclass(x)=character.selectSingleNode("class").text
    getlevel(x)=character.selectSingleNode("level").text

    ' ....
Next

Or you can choose for an approach that's slightly more elegant with the list, but needs you incrementing x every time:

Code:
Do
    set character = characters.nextNode()
    If character Is Nothing Then Exit Do

    ' ...
Loop
 
O

old.Yomar

Guest
Thanks Thorarin. I know the script still needs lots of improvement.

I didn't speak one word of VBScript until yesterday. Actually I've never programmed anything on PC's. Please be nice to me :)

The script works if you lower your browser security settings. I don't know of any other way to get it working in VB Script (tips are welcome). I have copied your suggestion to notepad so that I can use it when I implement the crafter thingy. The rest of the script is currently working and I've learned that... if it works, don't fix it :D But I will definitely use it for the crafters.

My main problem at the moment is that I'm not being able to work with . For some reason the server doesn't seem to support it. This means that every time somebody adds an alt to the guild, I have to edit 11 (!!!) files. Crazy ofcourse. If there's any workaround to this, I'd be really interested.

You seem to be a real programming guru Thorarin. Do you work in IT? Your XML parser is most, most impressive.
 
T

Thorarin

Guest
Originally posted by old.Yomar
The script works if you lower your browser security settings. I don't know of any other way to get it working in VB Script (tips are welcome).

The problem is that the object you're creating tries to fetch an XML file from a different server than the page it's residing on, which is not allowed by default.

In IE, instead of lowering all your security settings, you could add http://www.akebono.cistron.nl to your list of trusted sites (in the same dialog). You'll have to uncheck the https:// thing.

If the XML file were to be on your own server, it should run as well. Of course, that would mean you'd have to regularly upload a recent version of the XML file, but unsuspecting browsers would not get any weird errors. Of course, any other browser than IE of Windows will not do anything :(

My main problem at the moment is that I'm not being able to work with . For some reason the server doesn't seem to support it.

Those at SSI (Server Side Include) tags. Most servers that don't allow scripting, don't allow SSI either :( To my knowledge, Cistron personal homepages support only a few standard CGI scripts and nothing else...

This means that every time somebody adds an alt to the guild, I have to edit 11 (!!!) files. Crazy ofcourse. If there's any workaround to this, I'd be really interested.

11? Why 11? And well yes, there is a workaround. I've already given you the answer really :) You could place a custom XML file on your server with the data you normally include in the 11 files. It wouldn't give you any security problems either.

And yes, I work part-time as programmer at the moment. It's originally just a hobby, but well...

Question: set character = characters.nextNode()... why characters.nextNode() and not character.nextNode()? Is characters a variable name you assign yourself? Or should this be character.nextNode(), since the node is called character in the XML file?

I could have called the variables 'koe' and 'schaap' and it wouldn't have mattered. I called it 'characters' because it contains a list of <character> nodes. (see IXMLDOMNodeList).

The character variable points to the current node in that list. the nextNode() thing walks you through the list and returns a reference to the next node, which I store in 'character'.
 
O

old.Yomar

Guest
This is becoming a real programming course! :)

Why 11 files? Because for every sorting order I made a different script in a different HTML file. Why didn't I use subroutines? Because I have no idea how to update the data dynamically on the same page. Don't even know whether that is possible in VBScript (I'm such a n00b!).

The trusted site thingy is a great idea! I'll tell my members this. They'll love it.

As for putting the XML data on my own site. Nice idea, but if even remotely possible, I would like to automate the process completely. I'll definitely keep it in mind though.

I've tried to implement your script for getting the crafter data. It's not complete yet. Currently I only extract the crafts (that part works) and the fletchers (that part does not work).

In the d-loop something goes wrong. It seems I can't use selectSingleNode here, because all nodes have the same name (top_char). So I used childNodes, but it seems the syntax is wrong.

Code:
set crafts = xmlDoc.documentElement.childNodes(0).selectNodes("top")
For c = 0 To crafts.length - 1
	set craft = crafts.nextNode()
	gettype(c)=craft.getAttribute("type")
	For d = 1 To 5
		getfletcher(d)=craft.childNodes(d)
	Next
Next

I hate bothering you with this. Please do not feel obliged to reply. You have much better things to do. I'll keep on trying...
 
T

Thorarin

Guest
I wouldn't bother dynamicaly changing the page contents, but you can put all the sorting routines in the same HTML file and use the a GET parameter to select the one you need:

Code:
Select Case location.search
Case "?sortname"
    SortByName
Case "?sortrace"
    SortByRace
Case Else
    SortByName
End Select

Then you could name your file something like members.html and all the column headers would link to members.html?sortname, etc.

As for your loop: if you'd loop from 0 To 4, it'll work. It's not generally a good idea though, if the number of <top_char> lines would decrease, it would break your code.


Code:
dim guildNode
set guildNode = xmlDoc.documentElement.childNodes(0)

' ... member code here ...

dim crafts, toplist, topchar
set crafts = guildNode.selectNodes("top")

For c = 0 To crafts.length - 1
    set craft = crafts.nextNode()
    set toplist = craft.selectNodes("top_char")

    Select Case craft.getAttribute("type")
    Case "fletching"
        For I = 0 To toplist.length - 1
            set topchar = toplist.nextNode()
            getfletcher(I) = topchar.getAttribute("name")
            ' ... store points here as well
        Next
    Case "weaponcraft"
        ' rince and repeat
    Case "armorcraft"
        ' rince and repeat
    Case "tailoring"
        ' rince and repeat
    End Select
Next

This results in a bit of copied around code, which is usually a bad thing&reg;. It's solvable, but in this case it's not really worth it, IMHO.

And yes, I'm Dutch.
 
O

old.Yomar

Guest
Thorarin: you R U L E ! :) :) :)

It works like a freight train.

Everybody who cannot host PHP or ASP on their servers for whatever reason, this is IMHO a very nice solution for you:

You will need to adapt some lines for your own guild (like linking the character names to their mains, for example), but anyone with a little common sense should be able to do this.

The code could be polished a little (for example by using a sub routine for the main sort routine instead of repeating it countless times), but at least this works. I think it's good enough to be called version 1.0 :)
 
B

Bleri McThrust

Guest
Ok you have all lost me here :(

Ive tried reading about xml etc Ive tried looking at sites listed here, and there source code, but Im an html novice let alone xml.

We have a very basic website constructed using Frontpage. Is there an easy way to automatically grab the data and sort it using Frontpage ? If not can any one tell me what I need to do please ?
 
O

old.Yomar

Guest
Bleri, use my code :)

You can simply copy the HTML page and work from there. Note that the script links alts to mains and also contains temporary comments on members (like: raid probation until this and this date).

Even as a layerman you should be able to edit it a little to fit it to your guild. If you have any questions, don't hesitate to contact me :)

Script is working with crafter information now! It compares the names in the crafter section with the names in the guild section and then links the craft + crafter points to the guild member in question, so that you can sort all guild members on crafter points.

You'll love it :)

Have a look at www.akebono.cistron.nl and click on Roster (make sure you add our site to Trusted Sites in browser Internet Settings first). Only works in Internet Explorer.
 
B

Bleri McThrust

Guest
k thanks will try that.

Thieving code is no problem to me :p

Heres hoping
 
O

old.Yomar

Guest
Thorarin, your name has been mentioned in our roster.

It's the least I can do to thank you for all your help.

I'm done. What a task. But it worked.

Didn't speak one word VBScript until 2 days ago. Now this.

Wow :)

Once more thanks buddy!
 
T

Thorarin

Guest
Welcome ;)

A thing you might want to consider, is a a function like SwapEntries(I, J) :) It reduces your source code by 20 kB for one thing, and it becomes easier to maintain. At least it would be a step in the right direction :)


Code:
Function SwapEntries(I, J)
	temp = getname(I)
	temp2 = getlaston(I)
	temp3 = getrace(I)
	temp4 = getclass(I)
	temp5 = getlevel(I)
	temp6 = getrank(I)
	temp7 = getrp(I)
	temp8 = getrplastweek(I)
	temp9 = getanon(I)
	temp10 = definemain(I)
	temp11 = definejoined(I)
	temp12 = definecomments(I)
	temp13 = linkedfletcherpoints(I)
	temp14 = linkedweaponpoints(I)
	temp15 = linkedarmourpoints(I)
	temp16 = linkedtailorpoints(I)

	getname(I)=getname(J)
	getlaston(I)=getlaston(J)
	getrace(I)=getrace(J)
	getclass(I)=getclass(J)
	getlevel(I)=getlevel(J)
	getrank(I)=getrank(J)
	getrp(I)=getrp(J)
	getrplastweek(I)=getrplastweek(J)
	getanon(I)=getanon(J)
	definemain(I)=definemain(J)
	definejoined(I)=definejoined(J)
	definecomments(I)=definecomments(J)
	linkedfletcherpoints(I)=linkedfletcherpoints(J)
	linkedweaponpoints(I)=linkedweaponpoints(J)
	linkedarmourpoints(I)=linkedarmourpoints(J)
	linkedtailorpoints(I)=linkedtailorpoints(J)
	
	getname(J)=temp
	getlaston(J)=temp2
	getrace(J)=temp3
	getclass(J)=temp4
	getlevel(J)=temp5
	getrank(J)=temp6
	getrp(J)=temp7
	getrplastweek(J)=temp8
	getanon(J)=temp9
	definemain(J)=temp10
	definejoined(J)=temp11
	definecomments(J)=temp12
	linkedfletcherpoints(J)=temp13
	linkedweaponpoints(J)=temp14
	linkedarmourpoints(J)=temp15
	linkedtailorpoints(J)=temp16	
End Function

...

Case "?sortname"
	i=entries
	while (i=>1)
	j=1
	while (j<=i)
	if getname(j-1) > getname(j) then
		SwapEntries j-1, j
	End If
	j=j+1
	wend
	i=i-1
	wend

...
 
O

old.Yomar

Guest
Ah yes Thorarin, I was hoping there would be something for subroutines in VBScript. Thanks! It has been implemented and this looks a lot better (and smaller!) now.

Very nice! Thanks :)

The only weak point in the script still left is that it defines the end of the guildNode by the name of a certain member (starting with Z). This works, but will fail as soon as another member joins whose name comes later in the alphabet. I'll prolly need to do something with guildNode.length, but I will work on that later. It'll prolly take me a few hours to get it working hehe.
 
B

Bleri McThrust

Guest
Thanks Yomar

Been hacking away at your code and starting to get somewhere.

Not knowing what Im doing though makes it hard work lol
 
A

Arlone

Guest
Originally posted by old.Yomar
The only weak point in the script still left is that it defines the end of the guildNode by the name of a certain member (starting with Z). This works, but will fail as soon as another member joins whose name comes later in the alphabet. I'll prolly need to do something with guildNode.length, but I will work on that later. It'll prolly take me a few hours to get it working hehe.

Easy solution.

your current code:

Code:
x=0
y=0

while (x<>1)
       ' yada yada
if someone="someone" then y=1
x=x+1
wend

something like that right? But you DO gather the active charcount just above that line - sooo change it to...

Code:
getmembers = cint(xmlDoc.documentElement.childNodes(0).getAttribute("activechars"))

x=0

while (x<=getmembers)
         ' yada yada
x=x+1
wend

Works fine for me atleast.
 
T

Thorarin

Guest
No, the value of activechars is not the same as the total amount of characters in the XML file, it could be (and most likely is) less. That would mean random characters that happen to be at the end of the file will disappear.

The only right solution is to use selectNodes() and enumerate through the nodes..
 
S

Sazyasha

Guest
k, enough nodes to left and right, someone paste a code example for start/end elements and data retrieving for php <> xml, cause I got stuck :)

Guilds page worked fine, guilds list didn't, even though it seemed easier :)

Bet some wiz out there could paste an example how to handle the different XML files that Goa/Myth provides us with :)
 
G

Gef

Guest
For any peeps out there with PHP on their server who just want a really quick easy guild list. Just use an XSL template, I havent got a clue what half these people are jabbering on about. Seem to be overcomplicating a really easy situation.

http://www.g3f.co.uk/guild/

$file = "guildlist_num";

$aryParam = Array();
if($_GET["DT"] == "") $_GET["DT"] = "text";
if($_GET["SortBy"] == "")
{
$_GET["SortBy"] = "totalrp";
$_GET["DT"] = "number";
}
$aryParam["SortBy"] = $_GET["SortBy"];
$aryParam["DataType"] = $_GET["DT"];

if($_GET["DT"] == "number")
{
$file = "guildlist_num";
}
else
{
$file = "guildlist_text";
}

$xmlDom = domxml_open_file("http://www.camelot-europe.com/herald/servers/Prydwen/guilds/37.xml");

$xslDom = domxml_xslt_stylesheet_file("templates/$file.xsl");

$result = $objXsl->process($xmlDom, $aryParam);
print($result->dump_mem(true));

Then a simple XSL stylesheet

<?xml version="1.0" ?>

<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>

<xsl:eek:utput method="html" version="4.0" encoding="iso-8859-1"/>

<xsl:param name="SortBy"/>
<xsl:param name="DataType"/>

<xsl:template match="/">

<table width="100%">
<tr>
<td>



<xsl:for-each select="/guild_status/guild">
<h2><xsl:value-of select="@name"/></h2>
</xsl:for-each>
</p>





<table cellspacing="1" cellpadding="2" border="0" width="100%">
<tr bgcolor="#555555">
<td style="color: #FFFFFF;">Rank/Name:</td>
<td style="color: #FFFFFF;">Race:</td>
<td style="color: #FFFFFF;">Class:</td>
<td style="color: #FFFFFF;">Level:</td>
<td style="color: #FFFFFF;">Total RP:</td>
<td style="color: #FFFFFF;">Last Weeks RP:</td>
<td style="color: #FFFFFF;">Anon:</td>
</tr>

<xsl:for-each select="/guild_status/guild/character">
<xsl:sort select="*[name()=$SortBy]" order="descending"/>

<tr>
<xsl:choose>
<xsl:when test="position() mod 2"><xsl:attribute name="bgcolor">#ffffff</xsl:attribute></xsl:when>
<xsl:eek:therwise><xsl:attribute name="bgcolor">#f0f0f0</xsl:attribute></xsl:eek:therwise>
</xsl:choose>
<td><xsl:value-of select="guildrank"/> - <xsl:value-of select="@name"/> (<xsl:value-of select="@laston"/>)</td>
<td><xsl:value-of select="race"/></td>
<td><xsl:value-of select="class"/></td>
<td><xsl:value-of select="level"/></td>
<td><xsl:value-of select="totalrp"/></td>
<td><xsl:value-of select="lastweekrp"/></td>
<td><xsl:value-of select="anon"/></td>
</tr>

</xsl:for-each>

</table>
</p>
</td>
</tr>
</table>

</xsl:template>

</xsl:stylesheet>

Thats it ..
 
G

Gef

Guest
I actually had to make two stylesheets for the sorting because the sort option in XSL will only support one sort type. Seems really odd that it wont let you use an expression as the data type .. ho hum .. open to suggestions if anyone has a better idea?
 
A

Arlone

Guest
Originally posted by Thorarin
No, the value of activechars is not the same as the total amount of characters in the XML file, it could be (and most likely is) less. That would mean random characters that happen to be at the end of the file will disappear.

The only right solution is to use selectNodes() and enumerate through the nodes..

sounds very odd, why would there be more names in the XML-file than there are active chars? Uhm...

I better go have a look at that xml-file and return :)
 
A

Arlone

Guest
just checked. It seems as the activechars disregards inactive members... so I guess it work work perfectly if also did a check for inactive or not in the while-loop.

Activechars 18, chars in xml-file 22 (eg. 4 with inactive status)

while x<getmembers and inactiveVariable = false ?

anyway...
 
R

rhannoch

Guest
Well then it seems there is a lot of XML experts in here so i was just wondering if some could make a little guide on how it works or if just someone would like to send some Examples of there Xml crapper code for their guildlisting.

Why i am asking is that i am currently making a Herald site like the on camelotherald.com and i just need the guild listing at the moment.

Someone help PLEASE hehe

I do think i can get some more understanding of XML if i can get some samples to look at.

Hope some one can help.
 
D

DocWolfe

Guest
what I really meant to ask is.. has anyone done a member roster in asp which I can have a peak at, becuase tutorials are crap and I have no idea where to start from :p I know basic asp well.
 
O

old.Nikolas

Guest
Ahh.....lets have a try!

I have a guild website which i update using ftp upload programe on a regular basis.

So i have a blank page ready for a XML page, i can use dreamweaver, but am a novice.

what steps do i have to take to see some xml results?
 

Users who are viewing this thread

Top Bottom