How to load a simplexmlobject file into a variable
I am going crazy here...
I already have a SimpleXMLElement Object so it is not an XML file... I got it stored in a file object.txt
Now i want to put this object into a variable, but i can't get it to work...?
the SimpleXMLElement Object looks like this:
SimpleXMLElement Object ( [PubmedArticle] => Array ( [0] => SimpleXMLElement Object ( [MedlineCitation] => SimpleXMLElement Object ( [@attributes] => Array ( [Owner] => NLM [Status] => In-Process )
开发者_高级运维 [PMID] => 20538400
[DateCreated] => SimpleXMLElement Object
(
[Year] => 2010
[Month] => 07
[Day] => 08
)
[Article] => SimpleXMLElement Object
(
[@attributes] => Array
(
[PubModel] => Print-Electronic
)
.....etc etc....
how do i put this into a variable??
i tried this: $simplexml = file_get_contents('object.xml');
$simplexml should be an array
Loading simplexml from file: simplexml_load_file: $a = simplexml_load_file('object.xml');
If you need something else, please explain.
If your 'object.xml' file contains the above example and not actual XML, it looks a lot like you are using the results of a vardump, and you possibly wish to load that into a (or several) SimpleXMLElementObject(s)...
So, really, you have a string inside of a text file, and you want to parse out the contents. I found this: converting text file into xml using php? and thought it would be a good starting point.
精彩评论