The XML file is:
http://114.80.235.12
http://114.80.236.202
My PHP code is written like this, but I can't read it. Thank you.
2. Read Xml$xml_array=simplexml_load_file ("Wc.xml"); Reads the data from the XML into the array object in the foreach ($xml _array as $temp) {echo '";p Rint_r ($temp->f); echo"
";}
My goal is to read the middle of that two HTTP address. Thank you, sir.
Reply to discussion (solution)
Xpath= '//f[2]/text () '
Xpath= '//f[2]/text () '
Thank you, can I trouble you to say clearly, I Baidu a, no things
Print_r ($xml _array->a->f);
$s =<<< XML
http://114.80.235.12
http://114.80.236.202
XML; $xml = simplexml_load_string ($s);//normal traversal, need to know exactly where the target node is at the level of foreach ($xml as $temp
) { foreach ($temp->f as $v) echo "$v
XPath ('//f ') as $v) echo" $v
";
All can be obtained
http://114.80.235.12
http://114.80.236.202
[code=php] $s =<<< XML
Thank you brother for helping. Wish you happy every day.
I would like to strengthen my study, what is this knowledge? What knowledge should I search? Thank you, sir.
If you Print_r ($xml _array); You can see
SimpleXMLElement Object ( [@attributes] = = Array ( [TIME] = 180530 [vi] = 1 [ch] = 29 [NLS] = 0 [title] + [Control] [ code] = qt4j-61ws-q [enable] + 1 [logo] + 0 [WT] = 0 [band] =& Gt 0 ) [a] = = SimpleXMLElement Object ( [f] = = Array ( [0] =/http 114.80.235.12 [1] = http://114.80.236.202 ) ) [b] = simplexmlelement Object ( ))
Such a structure, it is easy to write code according to this. Don't repeat it.
XPath is a language that looks for information in an XML document. XPath is used to navigate through elements and attributes in an XML document.
You can search for XPath to find tutorials such as http://www.w3school.com.cn/xpath/
http://114.80.235.12
http://114.80.236.202XML; $doc = new
DOMDocument (); $doc->loadxml ($s); $xpath = new Domxpath ($doc); $query = '//f[1]/text () '; $entries = $xpath Evaluate ($query, $doc);//foreach ($entries as $entry) var_dump ($entry), foreach ($entries as $entry) echo $entry->data ; $xml = simplexml_load_string ($s); foreach ($xml->xpath ('//f[1]/text () ') as $v) echo $v;? >
Uh, a second address? #1的才正确
f[2]/text ()
The XPath counter is starting from 1.