Jump to content

$element->{name-with-minus} being completely ignored


ukweb

Recommended Posts

Hi all

 

I'm building a script which reads a XML document, and so far so good... until now!

 

the document uses '-' extensively all the way through it (not something that I would have chosen) so to combat this I've used {}.

 

The part of the document I am working on now, this simply does not work, and I really cannot see why...

 

XML

        <plot>
          <name-number>87</name-number>
          <price>183000</price>
          <bedrooms>4</bedrooms>
          <status>available</status>
          <summary>With three double bedrooms, including one en suite and a further bedroom plus family bathroom to the first floor,&nbsp;separate lounge and&nbsp;dining room with kitchen&nbsp;and utility to the ground floor, the Otter is a modern home with a great deal to offer growing families.</summary>
          <feature>Separate lounge and dining room</feature>
          <feature>Kitchen with utility room</feature>
          <feature>Integral garage</feature>
          <feature>En suite to master bedroom</feature>
          <property-type>detached-house</property-type>
          <media>
            <caption>
            </caption>
            <type>image</type>
            <filename>1855_Otter-WhitehirstGrange.jpg</filename>
            <indexno>1</indexno>
          </media>
          <media>
            <caption>
            </caption>
            <type>floorplan</type>
            <filename>1386_Otter-WhitehirstGrange.pdf</filename>
            <indexno>2</indexno>
          </media>
          <media>
            <caption>
            </caption>
            <type>brochure</type>
            <filename>284_brochure.pdf</filename>
            <indexno>3</indexno>
          </media>
          <style-name>Otter</style-name>
        </plot>

 

PHP

echo $plot->{name-number}; // echoes nothing, should echo 87
echo $plot->price; // echoes 183000
echo $plot->bedrooms // echoes 4
echo $plot->{style-name} // echoes nothing, should echo Otter

 

This is frustrating the hell out of me, and I cannot see why this would work everywhere else in the XML document but not here.

 

Any ideas or help would be received with gratitude!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.