Jump to content

XML - Testing.


Taalasmaa

Recommended Posts

Posted

Yo,

I'm very and I mean very newbie in XML.

I can script lua very well, but I'm not ever practised XML's.

I'm just testing this:

function test2(thePlayer)
mission = xmlLoadFile("test.xml")
local newFinish = xmlCreateChild(mission, "newMission" );
x,y,z = getElementPosition(thePlayer)
xmlNodeSetAttribute( newFinish, "posX", x );
xmlNodeSetAttribute( newFinish, "posY", y );
xmlNodeSetAttribute( newFinish, "posZ", z );
end
addCommandHandler("test", test2)

Why this isn't working.

In debugscript it's giving Bad Arguement @ xmlCreateChild, Bad Arguement @ xmlNodeSetAttribute

Thanks.

Posted

xmlNodeSetAttribute fails because xmlCreateChild fails.

xmlCreateChild seems ok, though. So I'm expecting that for some reason, test.xml couldn't be loaded. Perhaps you haven't this file yet? Or perhaps you've just got the wrong name / directory?

Posted
xmlNodeSetAttribute fails because xmlCreateChild fails.

xmlCreateChild seems ok, though. So I'm expecting that for some reason, test.xml couldn't be loaded. Perhaps you haven't this file yet? Or perhaps you've just got the wrong name / directory?

test.xml is in the same directory than the script itself.

Name is test.xml

And I got the file, so far. Also I checked that test.xml doesn't have any big letters like "Test.xml"-

Posted

might xml file dont get rootnode?

and u need specify parentnode for xmlcreatechild, not xml file itself i think

try

if not mission then
xmlCreateFile("test.xml","rootnode")
end

Posted
might xml file dont get rootnode?

and u need specify parentnode for xmlcreatechild, not xml file itself i think

try

if not mission then
xmlCreateFile("test.xml","rootnode")
end

Still not working :S. Any other things?

Posted

Really weird.. I added

resourceRoot = getResourceRootElement( getThisResource( ) )
addEventHandler("onResourceStart", resourceRoot,
function( )
local mission = xmlCreateFile ( "test.xml", "root" );
outputChatBox("test.xml created succesfully")
end
)

and removed old test.xml for test, but it's not EVEN creating new test.xml :o

Posted
This function creates a new XML document, which can later be saved to a file by using xmlSaveFile. This function will overwrite the file specified if it already exists.

Explanations, big or small, the Wiki has it all.

Posted
This function creates a new XML document, which can later be saved to a file by using xmlSaveFile. This function will overwrite the file specified if it already exists.
function test2()
if not xmlLoadFile( "test.xml" ) then
local mission = xmlCreateFile ( "test.xml", "root" );
local new1 = xmlCreateChild( mission, "newFinish" );
xmlSaveFile( mission );
end
end
addCommandHandler("test", test2)

Tried this too. It only Gives

<root/>

To test.xml file. It's not creating "newFinish".

Posted
function test2()
if not xmlLoadFile( "test.xml" ) then
local mission = xmlCreateFile ( "test.xml", "root" );
local new1 = xmlCreateChild( mission, "Car" );
vehicle = getPedOccupiedVehicle(source)
xmlNodeSetAttribute( new1, "Veh", vehicle );
xmlSaveFile( mission );
end
end
addCommandHandler("test", test2)

Okay, tried this1 too, now. It's not giving ANY errors in debugscript.. Just shows in test.xml.

And, I was in a car, lol.

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...