vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   xml to variable (https://vborg.vbsupport.ru/showthread.php?t=228352)

MyPornLife.info 11-19-2009 04:06 AM

xml to variable
 
hey.
the xml file name is: list.xml which is on http://domain/path/list.xml

its code is:
Code:

<note>
<to>
Tove
</to>
<from>
Jani
</from>
<heading>
Reminder
</heading>
<body>
Don't forget me this weekend!
</body>
</note>

now how can i get variable from that xml file?

so it will be like this: value of $heading will be 'Reminder'

any tutorial for me? plz help me

kh99 11-19-2009 01:18 PM

Well, if you want to do it in PHP, you could look at this: http://www.w3schools.com/php/php_xml_parser_expat.asp

If you want to do it in vB, you could use the class in includes/class_xml.php, and look at one of the files that uses it for an example, such as includes/adminfunctions_help.php.

That class parses xml in to an array. I made this test file which I put in my forum directory (and I put your xml in a file called "test.xml" in the same directory):

PHP Code:

<html><head></head><body>
<?php

$url 
"http://localhost/forums/test.xml";

require_once(
'./includes/class_xml.php');

$xmlobj = new vB_XML_Parser(false$url);
if (
$xmlobj->error_no == 1)
{
    echo(
"error, no url specified");
}
else if (
$xmlobj->error_no == 2)
{
    echo(
"error loading xml from '" $url "'");
}
else
{
    
$data $xmlobj->parse();
    
$heading $data['heading'];

    echo(
'$heading = \'' $heading "'");
}

?>

</body></html>


The output is:
Code:

$heading = ' Reminder '

Hope this helps.

MyPornLife.info 11-19-2009 01:56 PM

thank you very much :)
just what i was looking for..


All times are GMT. The time now is 11:48 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00954 seconds
  • Memory Usage 1,722KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete