In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the application of the name to access the XML document example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
One demand
Use the http://www.php.cn/code/8145.html" target= "_ blank" > getElementsByTagName method to access the data in the XML document by name.
Second analysis
Access XML documents by application name
First create an instance of the Microsoft parser using ActiveXObject, and then load the XML document into memory.
Then the getElementsByTagName () method is used to get the references to the number element, the name element, and the object element, and the result is an array, with each element in the array corresponding to an element in the XML document in the same order.
Finally, the value of the text contained in the corresponding element is obtained, and the string is spliced.
Three attentions
Count from 0 in the subscript of the array of JavaScript. The FirstChild attribute indicates that you want to access the text contained in the name element, not the name element itself; the data attribute gets the value of the node.
Four codes
1001 * * PHP 84971547 Changchun cak**@sina.com 1002 Dragon * * SQL 1234556 Wuhan ak**@sina.com
HTML code
Apply name to access XML document function get_xml () {var xmldoc,employesNode,employeNode,peopleNode; / / define variable var nameNode,titleNode,numberNode,displayText; / / define variable xmldoc = new ActiveXObject ("Microsoft.XMLDOM"); / / create Microsoft parser instance xmldoc.async = false; xmldoc.load ("index.xml") / / load the specified XML document numberNode=xmldoc.getElementsByTagName ("number") [1]; / / get the reference to the number element, access the employee's second piece of information nameNode=xmldoc.getElementsByTagName ("name") [1]; / / get the reference to the name element objectNode=xmldoc.getElementsByTagName ("object") [1]; telNode=xmldoc.getElementsByTagName ("tel") [1] / / realize the concatenation of strings and output the data in the XML document displayText= "employee Information: + numberNode.firstChild.data+','+nameNode.firstChild.data+','+ objectNode.firstChild.data+','+telNode.firstChild.data; div [XSS _ clean] = displayText; / / specify the information to output the string displayText in the tag identified by ID as div} Application name to access the XML document
Five running results
Thank you for reading this article carefully. I hope the article "sample Analysis of Application name access XML documents" shared by the editor will be helpful to you. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.