vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   LF Help on XML : Parsing error on equal sign, obvious something wrong - SOLVED! (https://vborg.vbsupport.ru/showthread.php?t=241230)

Vaupell 04-25-2010 10:10 AM

LF Help on XML : Parsing error on equal sign, obvious something wrong - SOLVED!
 
working on generating a xml file,

PHP Code:

$hentbrugere = ' select statement......';
$xmlfile = 'dir + filename......';
 
$file= fopen($xmlfile, "w");
 
$_xml ='<?xml version='."\"1.0\"".' encoding="ISO-8859-1"?>'."\r\n";
$_xml .="\r\n";
$_xml .="<users>\r\n";
 
while($row=$vbulletin->db->fetch_array($hentbrugere))
{
  $_xml .="<userid".'='."\"" . $row['userid'] . "\">\r\n";
  $_xml .="\t<username>" . $row['username'] . "</username>\r\n";
  $_xml .="\t<email>" . $row['email'] . "</email>\r\n";
  $_xml .="\t<usertitle>" . $row['usertitle'] . "</usertitle>\r\n";
  $_xml .="<".'/'."userid>\r\n";
}
 
$_xml .="</users>\r\n";
fwrite($file, $_xml);
fclose($file);

Creating file, filling file with content just fine..
And appears fine when looking in notepad or textreader..

But if i preview in a browser, or wysw...editor its bugged
browsers write

Parse error, and a pointer is pointing to the equal sign.
<userid="1">
-------^

so i thought maybe i needed to change equal sign to html with &amp;
PHP Code:

  $_xml .="<userid &amp; \"" $row['userid'] . "\">\r\n"

But same error

Partial of the generated xml file
Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
 
<users>
<userid="1">
    <username>Eqvaliser</username>
    <email>martin@localhost</email>
    <usertitle>Administrator</usertitle>
</userid>
</users>

it appears normal, but something is wrong.
And im thinking it might be i need to exscape the = sign in another way..

any advice . ? :confused:

--------------- Added [DATE]1272194760[/DATE] at [TIME]1272194760[/TIME] ---------------

Partial solved....

Adding a space to userid to user id works
Code:

$_xml .="<user id".'='."\"" . $row['userid'] . "\">\r\n";
Now the error is at the bottom instead..
</user id>
-------^
Code:

  $_xml .="<".'/'."user id>\r\n";
but the spacer is allready there.. hmmm...

--------------- Added [DATE]1272195046[/DATE] at [TIME]1272195046[/TIME] ---------------

SOLVED

Working loop is

PHP Code:

while($row=$vbulletin->db->fetch_array($hentbrugere))
{
  
$_xml .="<user id".'='."\"" $row['userid'] . "\">\r\n";
  
$_xml .="\t<username>" $row['username'] . "</username>\r\n";
  
$_xml .="\t<email>" $row['email'] . "</email>\r\n";
  
$_xml .="\t<usertitle>" $row['usertitle'] . "</usertitle>\r\n";
  
$_xml .="<".'/'."user>\r\n";




All times are GMT. The time now is 09:38 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.01259 seconds
  • Memory Usage 1,724KB
  • 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
  • (3)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)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