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
Do
set character = characters.nextNode()
If character Is Nothing Then Exit Do
' ...
Loop
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).
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.
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?
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
Select Case location.search
Case "?sortname"
SortByName
Case "?sortrace"
SortByRace
Case Else
SortByName
End Select
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
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
...
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.
x=0
y=0
while (x<>1)
' yada yada
if someone="someone" then y=1
x=x+1
wend
getmembers = cint(xmlDoc.documentElement.childNodes(0).getAttribute("activechars"))
x=0
while (x<=getmembers)
' yada yada
x=x+1
wend
$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));
<?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"
>
<xslutput method="html" version="4.0" encoding="iso-8859-1"/>
<xslaram name="SortBy"/>
<xslaram 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>
<xsltherwise><xsl:attribute name="bgcolor">#f0f0f0</xsl:attribute></xsltherwise>
</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>
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..