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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:03:38+00:00 2026-06-06T14:03:38+00:00

Here is the source xml: xml This is the xml of an fxg file

  • 0

Here is the source xml: xml

This is the xml of an fxg file produced by Adobe. The FXG document is valid xml, and it basically contains all the information for a document that can be edited. This specific question pertains to text that can be changed within the FXG so that the content can change.

I’m tryng to grab all the RichText elements and attributes within that element that have an attribute of s7:elementID using xpath relative location.

The source XML only has three total RichText elements, with only two of them having a s7:elementID

<?php

$url = "http://testvipd7.scene7.com/is/agm/papermusepress/HOL_12_F_green?&fmt=fxgraw";    
$xml = simplexml_load_file($url);       
$xml->registerXPathNamespace('default', 'http://ns.adobe.com/fxg/2008');
$xml->registerXPathNamespace('s7', 'http://ns.adobe.com/S7FXG/2008');
$textNode = $xml->xpath("//default:RichText/@s7:elementID");

print("<pre>".print_r($textNode,true)."</pre>");

?>

I got this far with help from another question. But the returned array is not what I was expecting. setting the xpath as I did, I am expecting it to select all the RichText elements that have an s7:elementID, as well as the other attributes of that element. However, it isn’t grabbing any of the other attributes of those elements. here is what it outputs:

Array
(
    [0] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [elementID] => smalltext
                )

        )

    [1] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [elementID] => largetext
                )

        )

)

If I take the exact same php but change the xpath like so:

$textNode = $xml->xpath("//default:RichText");

I get this array result:

Array
(
    [0] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [x] => 278.418
                    [y] => 115.542
                    [columnGap] => 18
                    [columnCount] => 1
                    [textAlign] => left
                    [fontFamily] => Trade Gothic LT Pro Bold Cn
                    [fontSize] => 11
                    [color] => #518269
                    [whiteSpaceCollapse] => preserve
                    [width] => 212.582
                    [height] => 33
                )

            [content] => SimpleXMLElement Object
                (
                    [p] => Array
                        (
                            [0] => SimpleXMLElement Object
                                (
                                    [span] => Scott, Anna, and Conner
                                )

                            [1] => SimpleXMLElement Object
                                (
                                    [span] => and our little one on the way
                                )

                        )

                )

        )

    [1] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [x] => 278.998
                    [y] => 86.7168
                    [columnGap] => 18
                    [columnCount] => 1
                    [textAlign] => left
                    [fontFamily] => Bootstrap
                    [fontSize] => 19
                    [color] => #518269
                    [whiteSpaceCollapse] => preserve
                    [trackingRight] => 4%
                    [width] => 240
                    [height] => 29
                )

            [content] => SimpleXMLElement Object
                (
                    [p] => SimpleXMLElement Object
                        (
                            [span] => THE JOHNSONS
                        )

                )

        )

    [2] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [x] => 278.418
                    [y] => 77.2373
                    [columnGap] => 0
                    [columnCount] => 1
                    [textAlign] => left
                    [fontFamily] => Trade Gothic LT Pro Bold Cn
                    [fontSize] => 11
                    [color] => #518269
                    [whiteSpaceCollapse] => preserve
                )

            [content] => SimpleXMLElement Object
                (
                    [p] => SimpleXMLElement Object
                        (
                            [span] => Array
                                (
                                    [0] => W
                                    [1] => ishing you the best this season.
                                )

                        )

                )

        )

)

If you notice, the first two array items don’t even have the info for the s7:elementID, but they are the two that should. The third does not have a s7:elementID by design.

Can anyone explain why I am getting these unexpected array results, with some attributes showing up, and others not?

UPDATE

Per dusan, i updated the php to:

$textNode = $xml->xpath("//default:RichText[@s7:elementID]");

Now the array only returns attributes of the element that do not have a prefix. I need all attributes, prefix and not.

Array
(
    [0] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [x] => 278.418
                    [y] => 115.542
                    [columnGap] => 18
                    [columnCount] => 1
                    [textAlign] => left
                    [fontFamily] => Trade Gothic LT Pro Bold Cn
                    [fontSize] => 11
                    [color] => #518269
                    [whiteSpaceCollapse] => preserve
                    [width] => 212.582
                    [height] => 33
                )

            [content] => SimpleXMLElement Object
                (
                    [p] => Array
                        (
                            [0] => SimpleXMLElement Object
                                (
                                    [span] => Scott, Anna, and Conner
                                )

                            [1] => SimpleXMLElement Object
                                (
                                    [span] => and our little one on the way
                                )

                        )

                )

        )

    [1] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [x] => 278.998
                    [y] => 86.7168
                    [columnGap] => 18
                    [columnCount] => 1
                    [textAlign] => left
                    [fontFamily] => Bootstrap
                    [fontSize] => 19
                    [color] => #518269
                    [whiteSpaceCollapse] => preserve
                    [trackingRight] => 4%
                    [width] => 240
                    [height] => 29
                )

            [content] => SimpleXMLElement Object
                (
                    [p] => SimpleXMLElement Object
                        (
                            [span] => THE JOHNSONS
                        )

                )

        )

)

UPDATE 2

changing the php to this seems to get all the attributes, both default and with the s7 prefix:

<?php
$url = "http://testvipd7.scene7.com/is/agm/papermusepress/HOL_12_F_green?&fmt=fxgraw";    
$xml = simplexml_load_file($url);       
$xml->registerXPathNamespace('default', 'http://ns.adobe.com/fxg/2008');
$xml->registerXPathNamespace('s7', 'http://ns.adobe.com/S7FXG/2008');
$textNode = $xml->xpath("//default:RichText[@s7:elementID]"); // //default:RichText[@s7:elementID]/@*

function pr($var) { print '<pre>'; print_r($var); print '</pre>'; }


foreach($textNode as $node){
    pr($node->attributes('http://ns.adobe.com/S7FXG/2008'));
    pr($node->attributes());
}
?>

And the XML Result:

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [caps] => none
            [colorName] => 
            [colorValue] => #518269
            [colorspace] => rgb
            [elementID] => smalltext
            [fill] => true
            [fillOverprint] => false
            [firstBaselineOffset] => ascent
            [joints] => miter
            [maxFontSize] => 11
            [miterLimit] => 4
            [referencePoint] => inherit
            [rowCount] => 1
            [rowGap] => 18
            [rowMajorOrder] => true
            [stroke] => false
            [strokeOverprint] => false
            [warpBend] => 0.5
            [warpDirection] => horizontal
            [warpHorizontalDistortion] => 0
            [warpStyle] => none
            [warpVerticalDistortion] => 0
            [weight] => 1
        )

)
SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [x] => 278.418
            [y] => 115.542
            [columnGap] => 18
            [columnCount] => 1
            [textAlign] => left
            [fontFamily] => Trade Gothic LT Pro Bold Cn
            [fontSize] => 11
            [color] => #518269
            [whiteSpaceCollapse] => preserve
            [width] => 212.582
            [height] => 33
        )

)
SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [caps] => none
            [colorName] => 
            [colorValue] => #518269
            [colorspace] => rgb
            [elementID] => largetext
            [fill] => true
            [fillOverprint] => false
            [firstBaselineOffset] => ascent
            [joints] => miter
            [maxFontSize] => 19
            [miterLimit] => 4
            [referencePoint] => inherit
            [rowCount] => 1
            [rowGap] => 18
            [rowMajorOrder] => true
            [stroke] => false
            [strokeOverprint] => false
            [warpBend] => 0.5
            [warpDirection] => horizontal
            [warpHorizontalDistortion] => 0
            [warpStyle] => none
            [warpVerticalDistortion] => 0
            [weight] => 1
        )

)
SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [x] => 278.998
            [y] => 86.7168
            [columnGap] => 18
            [columnCount] => 1
            [textAlign] => left
            [fontFamily] => Bootstrap
            [fontSize] => 19
            [color] => #518269
            [whiteSpaceCollapse] => preserve
            [trackingRight] => 4%
            [width] => 240
            [height] => 29
        )

)

now that it is able to retrieve all the attributes of the RichText element. How can I store certain attributes as a specific variable? For example, how can I set a variable for the s7:elementID and the fontSize attributes?

  • 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-06T14:03:40+00:00Added an answer on June 6, 2026 at 2:03 pm

    With //default:RichText/@s7:elementID you are selecting elementID attributes, not the RichText tag.

    Use this:

    $textNode = $xml->xpath("//default:RichText[@s7:elementID]");
    

    Update: The SimpleXMLElement::attributes docs says that:

    SimpleXML has made a rule of adding iterative properties to most methods. They cannot be viewed using var_dump() or anything else which can examine objects.

    So print_r is not showing to you all the information. Try getting the attributes using their namespace:

    foreach($textNode as $node){
        var_dump($node->attributes('http://ns.adobe.com/S7FXG/2008'));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The XML file is here . How can I get the source content in
I have this XML file that I parse into its elements and create a
This is a snippet of text from the source xml document: Great Lakes. The
Hey all. I've downloaded and moved the Xerces (v3.1.1) source here: /usr/include/xerces and I
From this XML source : <?xml version=1.0 encoding=utf-8 ?> <ROOT> <STRUCT> <COL order=1 nodeName=FOO/BAR
I have an open source application ( here ) This application get a character
I have a source list of xml in this format: <metadata> <metadatum> <description>OnEnter</description> <value>Hello
In a Ruby project I'm working with a badly formed xml file that comes
What's the easiest way in VB.NET to parse this XML? Here's an example of
I'm trying to parse the xml document returned from this link but I get

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.