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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:15:23+00:00 2026-06-11T16:15:23+00:00

I have some problems with an xml that has a a href link, that

  • 0

I have some problems with an xml that has a a href link, that I just can’t echo out in the right order.

XML :

<root>
      <x>290</x>
      <y>204</y>
      <width>420</width>
      <height>70</height>
        <htmlText>
                 <TEXTFORMAT LEADING="7">
                 <P ALIGN="CENTER">
                 <FONT FACE="Arial" SIZE="12" COLOR="#333333" LETTERSPACING="0" KERNING="0">
                 SOME TEXT 
                 <A HREF="mailto:some@email.com" TARGET="">
                 <U>some@email.com</U>
                 </A> SOME TEXT
                 </FONT>
                 </P>
                 </TEXTFORMAT>
                 </htmlText>
    </root>

My moduletext function :

<?php 
class modules
{
     private $xml;
     protected $build;
     // div text
     public $div_x, $div_y, $div_width, $div_height, $title, $post, $date, $caption_fontfamily, $caption, $caption_fontsize, $caption_color, $caption_ls, $serverEmail, $name, $email, $message, $src;

     private $direction, $fontFamily, $af_color, $color, $bold, $italic, $underline, $af_bold, $af_italic, $af_underline, $size;
     // P
     public $p_attr_color, $p_attr_align, $p_attr_fontfamily, $p_attr_fontsize, $p_content, $p_content_temp;
     // Image module
     private $img_path, $img_x, $img_y, $img_rotation, $img_width, $img_height;
     // Shape module
     private $shape_x, $shape_y, $shape_width, $shape_height, $fill_color, $border_color, $border_size, $shape_type, $alpha, $rotation, $prettyPrinting, $opacity;
    public function moduleText($xml,$print = '')
     {
         $this->xml = new SimpleXMLElement($xml);
         // Plocka ut XML-data
         $this->div_x = $this->xml->x;
         $this->div_y = $this->xml->y;
         $this->div_width = $this->xml->width;
         $this->div_height = $this->xml->height;
         $this->divStart = $this->xml->htmlText[0]->TEXTFORMAT->attributes->LEADING;
         $this->build = '<div id="printthis" style="position:absolute; overflow:auto;left:'.$this->div_x.'px;top:'.$this->div_y.'px;width:'.$this->div_width.'px;height:'.$this->div_height.'px;">';

     foreach($this->xml->htmlText as $htmltext)
         {
             foreach($htmltext as $textformat)
             {
             $line_height = $textformat->attributes()->LEADING;
                 foreach($textformat as $p)
                 {

                     foreach($p as $font)
                     {

                        if(isset($font->A))
                         {      


                         foreach($font->A as $link) {
                             $size = $link->attributes()->SIZE;
                             $target .= $link->attributes()->TARGET;

                             $this->build .= '<div style="width:100%; float:left; margin-left:5px; font-size:'.$size.'px;"><a href="' . str_replace("http://","",$link->attributes()->HREF) . '" target="'.$target.'" style="font-size:'.$size.'px;">'.str_replace(array("http://","mailto:"),"",$link->attributes()->HREF).'</a></div>';
                             } 
                         }
                         $fontsize = $font->attributes()->SIZE;
                         $fontfamily = str_ireplace(array('_'), array(''), $font->attributes()->FACE);
                         $fontcolor = $font->attributes()->COLOR;
                         $test = "1.305";
                         if(strlen($font) > 0) {
                         $this->build .= '<div align="'.$this->p_attr_align.'" style="width:100%; color:'.$fontcolor.';font-family:'.$fontfamily.';font-size:'.$fontsize.'px; line-height:'.$test.'em;">';
                         if(isset($font->A)) {
                         $this->build .= iconv('UTF-8','ISO-8859-1', str_ireplace(array('[b]','[/b]','[i]','[/i]'), array('<b>','</b>','<i>','</i>'), $font . '</div>')); 
                         } else {
                         $this->build .= iconv('UTF-8','ISO-8859-1', str_ireplace(array('[b]','[/b]','[i]','[/i]'), array('<b>','</b>','<i>','</i>'), $font . '</div>')); 
                         }
                         }
                         if(strlen($font->I) > 0) {
                         $this->build .= '<div align="'.$this->p_attr_align.'" style="width:100%;  color:'.$fontcolor.';font-family:'.$fontfamily.';font-size:'.$fontsize.'px; line-height:'.$test.'em;">';
                         $this->build .= iconv('UTF-8','ISO-8859-1', str_ireplace(array('[b]','[/b]','[i]','[/i]'), array('<b>','</b>','<i>','</i>'), "<i>".$font->I . '</i></div>'));
                     }

                     if(strlen($font->U) > 0) {
                         $this->build .= '<div align="'.$this->p_attr_align.'" style="width:100%; text-decoration:underline;  color:'.$fontcolor.';font-family:'.$fontfamily.';font-size:'.$fontsize.'px; line-height:'.$test.'em;">';

                         $this->build .= iconv('UTF-8','ISO-8859-1', str_ireplace(array('[b]','[/b]','[i]','[/i]'), array('<b>','</b>','<i>','</i>'), "<i>".$font->U . '</i>'));
                         $this->build .= '</div>';
                     }
                     if(strlen($font) == 0 && strlen($font->U) == 0 && strlen($font->I) == 0) {
                     $this->build .= '<div align="'.$this->p_attr_align.'" style="width:100%; text-decoration:underline;  color:'.$fontcolor.';font-family:'.$fontfamily.';font-size:'.$fontsize.'px; min-height:'.$test.'em; line-height:'.$test.'em;"></div>';
                     }

                     } 
                 }
              }
         }
         $this->build .= '</div>';
                return $this->build;
     }
            }
            ?>

PHP calling the method with xml:

<?php include("functions_modules.php"); 
$module = new modules; $xmlcode = '<root>
<x>290</x>
<y>204</y>
<width>420</width>
<height>70</height>
<htmlText>
<TEXTFORMAT LEADING="7">
<P ALIGN="CENTER">
<FONT FACE="Arial" SIZE="12" COLOR="#333333" LETTERSPACING="0" KERNING="0">
SOME TEXT
<A HREF="mailto:some@email.com" TARGET="">
<U>some@email.com</U>
</A>
SOME TEXT
</FONT></P>
</TEXTFORMAT>
</htmlText>
</root>'; 
echo $module->moduleText($xmlcode); ?>

The result becomes this :

SOME TEXT
SOME TEXT
<a href="mailto:some@email.com">some@email.com</a>

It should be:

SOME TEXT
some@email.com
SOME TEXT

  • 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-11T16:15:24+00:00Added an answer on June 11, 2026 at 4:15 pm

    I hope this is helpful. I enjoy using xpath to cut through the XML I get back from SimpleXML:

    <?php
    $xml = new SimpleXMLElement("xml_file_path", NULL, True);
    $tags = $xml->xpath('//a');  //use xpath on the XML to find the a tags
    
    foreach($tags as $tag){  
        echo $image['href'] ;  //here is the a tag src
    }
    ?>
    

    try this link

    http://php.net/manual/en/book.simplexml.php

    Reading an XML file and store data to mysql database

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

Sidebar

Related Questions

I have some problems with Javascript. In fact, I'm just newbie in that script
Has anyone had this problem? My projects tend to have some long XML files
i have some problems with a Query seem IN dosen't work with Group_concat, that
I have some problems with a PHP script that calls a Bash script.... in
Edit: After addressing some issues that may or may not have been causing problems,
I have some Java code that determines the namespace of the root-level element of
I have a file which is an XML representation of some data that is
I have some problems figuring out how to group to certain variables in javascript.
I have some problems with my XML parser, written in obj-c. The parser itself
I have some problem when unmarshaling a .xml at a web service using JAXB.

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.