simplexml

Ignore comment node in SimpleXML [duplicate]

拥有回忆 提交于 2021-02-11 06:10:25
问题 This question already has an answer here : Closed 9 years ago . Possible Duplicate: find and edit comment element of html with php I have a comment in my XML file. If I load it with SimpleXML and then var_dump the node ( var_dump($xml->node->comment); ), it looks like this. ["comment"]=> object(SimpleXMLElement)#54 (0) { } The corresponding XML would look like this. <root> <node> <!-- some comment --> </node> </root> If I want to dynamically parse this, how can I detect if this

Access SimpleXML node value as string

柔情痞子 提交于 2021-02-08 11:26:30
问题 I have an object called $picasa_feed like this: SimpleXMLElement Object ( [guid] => https://picasaweb.google.com/data/entry/base/user/0000000000000000/albumid/0000000000000000?alt=rss&hl=en_US [pubDate] => Fri, 12 Dec 2008 20:00:00 +0000 [category] => http://schemas.google.com/photos/2007#album [title] => My Pictures [description] => ... [link] => https://picasaweb.google.com/0000000000000000/MyAlbum [author] => Me ) I want to take put a property value into an element of an associative array:

How to parse <media:content> tag in RSS with simplexml

别等时光非礼了梦想. 提交于 2021-02-07 18:14:08
问题 Structure of my RSS from http://rss.cnn.com/rss/edition.rss is: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?> <?xml-stylesheet type="text/css" media="screen" href="http://rss.cnn.com/~d/styles/itemcontent.css"?> <rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">

How to parse <media:content> tag in RSS with simplexml

谁说我不能喝 提交于 2021-02-07 18:13:48
问题 Structure of my RSS from http://rss.cnn.com/rss/edition.rss is: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?> <?xml-stylesheet type="text/css" media="screen" href="http://rss.cnn.com/~d/styles/itemcontent.css"?> <rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">

How to parse <media:content> tag in RSS with simplexml

守給你的承諾、 提交于 2021-02-07 18:13:07
问题 Structure of my RSS from http://rss.cnn.com/rss/edition.rss is: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?> <?xml-stylesheet type="text/css" media="screen" href="http://rss.cnn.com/~d/styles/itemcontent.css"?> <rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">

Accessing processing instructions with PHP's SimpleXML

家住魔仙堡 提交于 2021-01-29 17:51:58
问题 Pretty straightforward -- Is there any way to access the data of a processing instruction node using SimpleXML? I understand that SimpleXML is, well, simple; as a result it has a number of limitations, predominantly working with mixed content nodes. An example: Test.xml <test> <node> <?php /* processing instructions */ ?> </node> </test> Parse.php $test = simplexml_load_file('Test.xml'); var_dump($test->node->php); // dumps as a SimpleXMLElement, so it's sorta found, // however string casting

How can I count the amount of lines of an HTML code with PHP?

本小妞迷上赌 提交于 2021-01-29 08:13:38
问题 I have some HTML generated by a WYSIWYG-editor (WordPress). I'd like to show a preview of this HTML, by only showing up to 3 lines of text (in HTML format). Example HTML: (always formated with new lines) <p>Hello, this is some generated HTML.</p> <ol> <li>Some list item<li> <li>Some list item</li> <li>Some list item</li> </ol> I'd like to preview a maximum of 4 lines of text in this formated HTML. Example preview to display: (numbers represent line numbers, not actual output). Hello, this is

Accessing a nested node in an XML load by SimpleXMLElement

橙三吉。 提交于 2021-01-29 06:50:52
问题 I have an XML file with this structure. <?xml version="1.0" encoding="ISO-8859-1"?> <COMMUNITIES> <COMMUNITY ID="c001"> <NAME>Town Services</NAME> <TOP>50</TOP> <LEFT>50</LEFT> <WIDTH>200</WIDTH> <HEIGHT>300</HEIGHT> <URLS> <URL ID="U001"> <NAME>Google.com</NAME> <URL>http://www.google.com</URL> </URL> <URL ID="U002"> <NAME>Bing.com</NAME> <URL>http://www.bing.com</URL> </URL> <URL ID="U003"> <NAME>Yahoo.com</NAME> <URL>http://www.yahoo.com</URL> </URL> <URL ID="U004"> <NAME>Aol.com</NAME>

Error on strings that contains “&” in XML. How can I fix this?

99封情书 提交于 2021-01-28 01:49:23
问题 I am using the following code to import my data from XML to mySQL. Is there any way to encode & before loading it using PHP instead of manually change it from the file? this is the error Warning: simplexml_load_file() [function.simplexml-load-file]: products.xml:4: parser error : xmlParseEntityRef: no name in ... on line 5 Warning: simplexml_load_file() [function.simplexml-load-file]: <description> DAYLIGHT & LED / SMD Tech</description> in ... on line 5 Warning: simplexml_load_file()

echo simplexml object

 ̄綄美尐妖づ 提交于 2020-05-23 10:52:09
问题 This question has two parts. Part 1. Yesterday I had some code which would echo the entire content of the XML from an RSS feed. Then I deleted it from my php document, saved over it, and I am totally kicking myself. I believe the syntax went something like this: $xml = simplexml_load_file($url); echo $xml; I tried that again and it is not working, so apparently I forgot the correct syntax and could use your help, dear stackoverflow question answerers. I keep trying to figure out what I was