Jump to content

XML and Memo


Recommended Posts

Hello, well I'm actually having some problemos with getting the text from an xml file and using guiSetText with a memo, here's my code

c.lua

GUIEditor.memo[2] = guiCreateMemo(169, 27, 395, 194, "", false, GUIEditor.window[1]) 
GUIEditor.gridlist[1] = guiCreateGridList(10, 27, 156, 219, false, GUIEditor.window[1]) 
topics = guiGridListAddColumn(GUIEditor.gridlist[1], "Topics", 0.9) 
rulesRow = guiGridListAddRow(GUIEditor.gridlist[1]) 
guiGridListSetItemText ( GUIEditor.gridlist[1], rulesRow, topics, "Rules", false, false ) 
  
if (guiGridListGetSelectedItem (GUIEditor.gridlist[1]) == rulesRow) then 
local xmlRules = xmlLoadFile ( "rules.xml" ) 
local Rulesnode = xmlFindChild( xmlRules, "rules", 0 ) 
local RulesValue = xmlNodeGetValue ( Rulesnode ) 
guiSetText (GUIEditor.memo[2], tostring ( RulesValue ) ) 

rules.xml

<rules> 
Under construction for now. 
</rules> 

meta.xml

<meta> 
<script src="c.lua" type="client"/> 
<file src="rules.xml" type="client"/> 
</meta> 

Link to comment
GUIEditor.memo[2] = guiCreateMemo(169, 27, 395, 194, "", false, GUIEditor.window[1]) 
GUIEditor.gridlist[1] = guiCreateGridList(10, 27, 156, 219, false, GUIEditor.window[1]) 
topics = guiGridListAddColumn(GUIEditor.gridlist[1], "Topics", 0.9) 
rulesRow = guiGridListAddRow(GUIEditor.gridlist[1]) 
guiGridListSetItemText ( GUIEditor.gridlist[1], rulesRow, topics, "Rules", false, false ) 
  
if (guiGridListGetSelectedItem (GUIEditor.gridlist[1]) == rulesRow) then 
local xmlRules = xmlLoadFile ( "rules.xml" ) 
local RulesValue = xmlNodeGetValue ( xmlRules) 
guiSetText (GUIEditor.memo[2], tostring ( RulesValue ) ) 

meta

<meta> 
<script src="c.lua" type="client"/> 
<file src="rules.xml" 
</meta> 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...