0

Im trying to get a XML node (with children) as string but had no success.

Here my xml

 <?xml version="1.0" encoding="UTF-8"?> <params> <main_settings> <id>23</account_id> <test/> <logo_url/> <app appid="test_12"> <d:tag xmlns:c="http://mypage.com/test2" id="mypage_id_256" type="mypage_type_test"> <path-info value="show"/> </d:tag> </app> </main_settings> </params> 

This is not working.

 $var->params->main_settings->app; 

Is there a way to get with simpleXML a nodes ("app") childs as sting?

2
  • What are you trying to get as your text in that example? test_12? Commented Jan 29, 2013 at 18:03
  • No. i need the node d:tag tag as string. Commented Jan 29, 2013 at 18:05

1 Answer 1

1

You can call the asXml method on the child:

$var->params->main_settings->app->asXml(); 

It's also possible via typecasting:

(string)$var->params->main_settings->app 
Sign up to request clarification or add additional context in comments.

6 Comments

I tried this. But the childrens are not in the string. Just the node "d:tag".
Could you post your output and code? I'm not sure if we're talking about the same, because d:tag IS a children of app.
Im sure, we are talking about the same issue. My problem is, that i cannot write the complete node in html. Firefox just shows mothertag. The children are not included. With htmlspecialchars i can see it completly
Can you see the children when you display the source code in Firefox?
I can see "d:tag" in by using $xml->asXML(); Bu i need only "d:tag" as string. I dont mean the contents in "d:tag". I need the full node as String "<d:tag ....... </d:tag>"
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.