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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:48:16+00:00 2026-05-19T13:48:16+00:00

I’m reading an xml file generated by a 3rd-party application that includes the following:

  • 0

I’m reading an xml file generated by a 3rd-party application that includes the following:

<Cell>
    <Comment ss:Author="Mark Baker">
        <ss:Data xmlns="http://www.w3.org/TR/REC-html40"><B><Font html:Face="Tahoma" html:Size="8" html:Color="#000000">Mark Baker:</Font></B><Font html:Face="Tahoma" html:Size="8" html:Color="#000000">&#10;Comment 1 - No align</Font></ss:Data>
    </Comment>
</Cell>

What I’m trying to do is access the raw data from the Cell->Comment->Data element either “as is” or as an actual block of (X)HTML markup (preferably the latter).

if (isset($cell->Comment)) {
    echo 'comment found<br />';
    $commentAttributes = $cell->Comment->attributes($namespaces['ss']);
    if (isset($commentAttributes->Author)) {
        echo 'Author: ',(string)$commentAttributes->Author,'<br />';
    }
    $commentData = $cell->Comment->children($namespaces['ss']);
    var_dump($commentData);
    echo '<br />';
}

gives me:

comment found
Author: Mark Baker
object(SimpleXMLElement)#130 (2) { ["@attributes"]=> array(1) { ["Author"]=> string(10) "Mark Baker" } ["Data"]=> object(SimpleXMLElement)#129 (0) { } } 

while

if (isset($cell->Comment)) {
    echo 'comment found<br />';
    $commentAttributes = $cell->Comment->attributes($namespaces['ss']);
    if (isset($commentAttributes->Author)) {
        echo 'Author: ',(string)$commentAttributes->Author,'<br />';
    }
    $commentData = $cell->Comment->Data->children();
    var_dump($commentData);
    echo '<br />';
}

gives me:

comment found
Author: Mark Baker
object(SimpleXMLElement)#129 (2) { ["B"]=> object(SimpleXMLElement)#118 (1) { ["Font"]=> string(11) "Mark Baker:" } ["Font"]=> string(21) " Comment 1 - No align" } 

Unfortunately, simpleXML seems to be treating the whole element as a series of XML nodes. I’m sure I should be able to get this is raw data without complex looping, or feeding the element to a DOM Parser; perhaps using the xmlns=”http://www.w3.org/TR/REC-html40&#8243; namespace to extract this cleanly, but I can’t figure out how.

Any help appreciated.

A more complex example of the XML data:

<Cell>
    <Comment ss:Author="Mark Baker">
        <ss:Data xmlns="http://www.w3.org/TR/REC-html40">
            <B><Font html:Face="Tahoma" html:Size="8" html:Color="#000000">Mark Baker:</Font></B><Font html:Face="Tahoma" html:Size="8" html:Color="#000000">&#10;</Font><B><Font html:Face="Tahoma" x:Family="Swiss" html:Size="8" html:Color="#000000">Rich </Font><U><Font html:Face="Tahoma" x:Family="Swiss" html:Size="8" html:Color="#FF0000">Text </Font></U><Font html:Face="Tahoma" x:Family="Swiss" html:Size="8" html:Color="#000000">Comment</Font></B><Font html:Face="Tahoma" html:Size="8" html:Color="#000000"> Center Aligned</Font>
        </ss:Data>
    </Comment>
</Cell>
  • 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-19T13:48:16+00:00Added an answer on May 19, 2026 at 1:48 pm

    I’ve gone with a quick and dirty solution for the time being. In the longer term, I’ll switch to using XMLReader (for all the reasons mentioned)… I just don’t have the time to rewrite all the existing simpleXML code at the moment.

    I’ve gone with:

    $node = $cell->Comment->Data->asXML();
    $comment = substr($node,49,-10);
    $comment = strip_tags($comment);
    

    While I’d prefer to keep the HTML markup, that will require additional work, so I’m simply stripping all the markup leaving me with the plain text (which is the critical element).

    While this is a far from perfect solution, it does what I need it to do (for the moment), and I can move on to the next item in my “to do” list, having already added a new item of “rewrite using XMLReader” to that list.

    Thanks for the help. I’ll be sure to revisit this thread when I am doing that rewrite.

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

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the

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.