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 8362061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:51:20+00:00 2026-06-09T11:51:20+00:00

I am trying to dynamically create XML but i’ve run into a snag, for

  • 0

I am trying to dynamically create XML but i’ve run into a snag, for somereason it’s automatically encoding the < and >, i need it to stop that because it’s breaking my tags but i can’t see anywhere in my function it’s tell it to encode.

function GenerateList($titleB, $descB, $thumbB, $dirB, $patternB){
if (is_dir($dirB)){
$myDirectory = opendir($dirB);
// get each entry
while($entryName = readdir($myDirectory)) {
    $dirArray[] = $entryName;
}

// close directory
closedir($myDirectory);

//  count elements in array
$indexCount = count($dirArray);
print ("<center><h1>'$titleB' Directory</h1>");
$true_count = 0;

// sort em
sort($dirArray);
$outputB = "<CATEGORY name=\"$titleB\" desc=\"$descB\" thumb=\"$thumbB\">";
print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>");
print("<TR><TH>Filename</TH><th>Filesize</th><TH>Filename</TH><th>Filesize</th><TH>Filename</TH><th>Filesize</th></TR>");
print("<TR><TD colspan=2><TABLE border=0 cellpadding=0 cellspacing=0 class=whitelinks>");
// loop through the array of files and print them all
$one_third = round($indexCount/3);
$two_third = $one_third+$one_third;
for($index=0; $index < $indexCount; $index++) {
    $ext = explode(".", $dirArray[$index]);
    $parsed_title = preg_replace ($patternB, "", $ext[0]);
    if ((substr("$dirArray[$index]", 0, 1) != ".")&&($ext[1] == "flv")){ // don't list hidden files
        $true_count++;
        print("<TR><TD><a href=\"$dirB$dirArray[$index]\">$parsed_title</a></td>");
        print("<td>");
        print(filesize($dirB.$dirArray[$index]));
        print("</td>");
        print("</TR>");
            if ($one_third == ($index+1) || $two_third == ($index+1)){
                print("</td></TR></table>");
                print("</TD><TD colspan=2><TABLE border=0 cellpadding=0 cellspacing=0 class=whitelinks>");
            }
        $outputB .= "<ITEM>";
        $outputB .= "<file_path>/$dirB".htmlentities($dirArray[$index])."</file_path>";
        $outputB .= "<file_width>500</file_width>";
        $outputB .= "<file_height>375</file_height>";
        $outputB .= "<file_title>".$parsed_title."</file_title>";
        $outputB .= "<file_desc>Loaded from a seperate txt file, index to match with the index of the dir file</file_desc>";
        $outputB .= "<file_image>$thumbB</file_image>";
        $outputB .= "<featured_image>$thumbB</featured_image>";
        $outputB .= "<featured_or_not>true</featured_or_not>";
        $outputB .= "</ITEM>";
    }
}
print("</td></TR></table>");
print("</TR><td colspan=6 align=right>$true_count files</td></TABLE>");
};//if (file_exists($dirB))
$outputB .= "</CATEGORY>";
return $outputB;
};//function

then i take the final output of several function calls and pass it to the xml parser

//$output = concatoniated returns of several GenerateList functions
$dom = new DOMDocument(‘1.0’, ‘utf-8’);

$element = $dom->createElement('CONTENT',$output);

$dom->appendChild($element);
  $xml_final = $dom->saveXML(); 
  $dom->save("playlist.xml") 
  • 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-06-09T11:51:21+00:00Added an answer on June 9, 2026 at 11:51 am

    PHP isn’t my thing but to get you on your way.

    DOMDocument should have a method something like LoadXml.

    So you need to put a bit more in your $output, ?xml tag and a root node etc, then create a DoMDocument and call LoadXml($output)

    Or something similar any way.

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

Sidebar

Related Questions

I am trying to dynamically create a XML for a webservice but when I
I am trying to dynamically create an XML file using php like this: header
I'm trying to dynamically create a book from code server-side. That part's working fine,
I'm trying to dynamically create a bunch of class properties, but each dynamic fget
I am trying to create a dynamically generated XML file from Java. This is
Im trying to create a page for a university project that dynamically displays a
I am trying to create a postage label that is populated dynamically in C#.
im trying to create an xml data into JSP using a resource file: MyData.properties
I'm trying to dynamically create a map collection but I am still new to
I'm trying to dynamically create some table rows, but on the Table Row I

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.