Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7517511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:28:33+00:00 2026-05-30T01:28:33+00:00

I am having some trouble mixing PHP with XML. I currently have a PHP

  • 0

I am having some trouble mixing PHP with XML.

I currently have a PHP file that takes variables from the URL string and I need to calculate something based on these variables, and then return the output in an XTML format.

I currently have my main config file that links to my xml generating file:

include('Xml.php');

$x = new xml();
$x->generate();

And my XML generating file is as follows:

<?php

Class XML {

public function generate() {
    $doc = new DOMDocument('1.0');
    $doc->formatOutput = true;

    $root = $doc->createElement('conv');
    $root = $doc->appendChild($root);

    $at = $doc->createElement('at');
    $at = $root->appendChild($at);

    $text = $doc->createTextNode("hi");
    $text = $at->appendChild($text);

    echo $doc->saveXML();
}
}
?>

But this doesn’t work – what am I doing wrong here – I know it’s probaby obvious but I am new to XML and can’t seem to get it working!

Should I be doing it differently? If so … how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:28:34+00:00Added an answer on May 30, 2026 at 1:28 am

    I’ve just tested your class with following code:

    $xml = new XML();
    $xml->generate();
    

    And I’ve got this result:

    [vyktor@grepfruit tmp]$ php test.php 
    <?xml version="1.0"?>
    <conv>
      <at>hi</at>
    </conv>
    

    So your class works just fine and your error is somewhere else, eg. including wrong file.

    Turn on error_reporting and paste errors in comment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having some trouble sending properly formatted HTML e-mail from a PHP script. I am
Im having some trouble looping through some xml data. The xml file is structured
Having some trouble passing values from one class to another. I basically have a
Im having some trouble reading xml files using jquery that containts swedish chars (åäö)
I´m having some trouble retrieving a collection of strings in a projection: say that
Im having some trouble writing a getstring function, this is what I have so
I am having some trouble with the Google Maps API . I have an
I'm having some trouble getting log4net to work from ASP.NET 3.5. This is the
I having some trouble figuring this problem out where I have one button which
I'm having some trouble opening an existing blackberry eclipse project I have to work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.