Fork me on GitHub

#1 2015-10-13 18:40:53

lavvaf
Member
Registered: 2015-10-09
Posts: 29

Work with xml file!

Hi All,

I want to develop a new app and create a XML config file of my application inside the user's
configurations directory.
Could you help me do it?

I really appreciate your help in resolving the problem.
Thanks

Offline

#2 2015-10-13 23:25:25

lars-sh
Administrator
From: near Hamburg, Germany
Registered: 2011-07-14
Posts: 731
Website

Re: Work with xml file!

You can read a user's xml configuration using:

$xml = eyeXML('getXMLconfig', array('yourApp', 'conf.xml'));

You can write a user's xml configuration using:

eyeXML('setXMLconfig', array('yourApp', 'conf.xml', $xml));

Those xml configurations do not use xml attributes nor more advanced xml elements. The following example shows you the schema of that $xml variable:

<root>
	<a>
		<c>C</c>
	</a>
	<b>
		<d>D1</d>
		<e>E</e>
		<d>D2</d>
	</b>
</root>
$xml['root'][0]['a'][0]['c'][0] = 'C';
$xml['root'][0]['b'][0]['d'][0] = 'D1';
$xml['root'][0]['b'][0]['e'][0] = 'E';
$xml['root'][0]['b'][0]['d'][1] = 'D2';

Best regards,
Lars Knickrehm

The oneye project.

Offline

#3 2015-10-14 12:29:33

lavvaf
Member
Registered: 2015-10-09
Posts: 29

Re: Work with xml file!

Dear Lars,

Thank you for getting back to me, your information is very very useful.
May I ask you explain me how to create a XML config file of my application inside the user's configurations directory?
I'm looking for user run the app, the XML file create automatically in user's configurations directory.
I have another question that hope you help me, What is the global $myPid and global $checknum? What is these variables usage?

Best Regards

Last edited by lavvaf (2015-10-14 14:24:21)

Offline

#4 2015-10-14 19:05:10

lars-sh
Administrator
From: near Hamburg, Germany
Registered: 2011-07-14
Posts: 731
Website

Re: Work with xml file!

$xml = eyeXML('getXMLconfig', array('yourApp', 'conf.xml'));
if (!is_array($xml)) {
    $xml = array( [...] );
}

$myPid is the internal process ID, $checknum is used to identify a process when doing web service calls.


Best regards,
Lars Knickrehm

The oneye project.

Offline

#5 2015-10-15 09:04:20

lavvaf
Member
Registered: 2015-10-09
Posts: 29

Re: Work with xml file!

lars-sh wrote:
$xml = eyeXML('getXMLconfig', array('yourApp', 'conf.xml'));
if (!is_array($xml)) {
    $xml = array( [...] );
}

$myPid is the internal process ID, $checknum is used to identify a process when doing web service calls.

Dear Lars,

First thanks for your information.
If I understand you correctly, when running the app, this code creates a new folder in user's configurations directory and then create a conf.xml. is it correct? unfortunatly after added the code to my application, it isn't running!

here in my code:

 function HelloWorld_run($params = '') {
	$xml = eyeXML('getXMLconfig', array('HelloWorld', 'conf.xml'));
	if (!is_array($xml)) {
		$xml = array( [...] );
	}
 ...
 }

May I ask you correct me?
Thanks

Offline

#6 2015-10-15 09:32:52

lars-sh
Administrator
From: near Hamburg, Germany
Registered: 2011-07-14
Posts: 731
Website

Re: Work with xml file!

Did you replace all [...] with your own content?!


Best regards,
Lars Knickrehm

The oneye project.

Offline

#7 2015-10-15 10:10:13

lavvaf
Member
Registered: 2015-10-09
Posts: 29

Re: Work with xml file!

lars-sh wrote:

Did you replace all [...] with your own content?!

Dear Lars,
I corrected my code:

 function HelloWorld_run($params = '') {
	$xml = eyeXML('getXMLconfig', array('HelloWorld', 'conf.xml'));
	if (!is_array($xml)) {
		$xml = array(['HelloWorld'][0]);
		eyeXML('setXMLconfig', array('HelloWorld', 'conf.xml', $xml));
	}
 ...
 }

It's work!!!! Thanks a lot...

Offline

Board footer

Powered by FluxBB