0

How to parse this type of files in php I have tried using

<?php
$xml ="office.xml";

// get first book title
$title=$xml->featureMember->AA_OFFICE;
// show title
echo $title;
echo '<br/>';
?>

if iam using gml:featuremember instead of featuremember i am getting an error in syntax if i use featuremember iam getting ) Notice: Trying to get property of non-object

<gml:boundedBy>
<gml:null>unknown</gml:null>
</gml:boundedBy>
<gml:featureMember>
<kgp:AA_OFFICE fid="AA_OFFICE.1">
<kgp:the_geom>
<gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#32645">
<gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">643630.3815,2498825.0741</gml:coordinates>
</gml:Point>
</kgp:the_geom>
<kgp:Name>MANMARK EXPORT PVT LTD</kgp:Name>
<kgp:Type/>
<kgp:Plot_No>55</kgp:Plot_No>
<kgp:Block_Name>AA</kgp:Block_Name>
</kgp:AA_OFFICE>
</gml:featureMember>
3
  • you're doing it wrong, checkout SimpleXMLElement ... Commented May 30, 2012 at 18:41
  • Do you mean $xml = simplexml_load_file("office.xml")? Commented May 30, 2012 at 18:42
  • i have changed $xml ="office.xml"; to $xml = simplexml_load_file("office.xml") But there is no change can u explain Commented May 30, 2012 at 18:46

2 Answers 2

1

You are trying to use a string as an object. You have to create some form of XML Parsing object first. For example,

$xmlDoc = new DOMDocument();
$xmlDoc->load("office.xml");

More information

or

$xml = simplexml_load_file("office.xml");

More information

Sign up to request clarification or add additional context in comments.

1 Comment

if I change $xmlDoc = new DOMDocument(); $xmlDoc->load("office.xml"); then i am getting Notice: Undefined property: DOMDocument::$featureMember this error
0

try to debug your xml

libxml_use_internal_errors(true);
$xml = simplexml_load_file("office.xml");
var_dump(libxml_get_errors());

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.