Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How php changes the value of xml nodes

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "how php changes the value of xml nodes". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how php changes the value of xml nodes.

Php changes the value of xml nodes: 1, read data from the database; 2, write a xml file; 3, create DOMDocument objects and load xml files; 4, modify the value of child nodes under the specified node.

Operating environment of this article: Windows7 system, PHP7.1 version, Dell G3 computer

How does php change the value of xml nodes?

Php modifies the value of the xml node

Today just realized the function, found a lot of information, originally wanted to use xpath, but because I don't know much about xpath. After a big circle, I decided to use DOMDocument to do it.

Make a mark here so that you don't have to work too hard to find information in the future.

First read the data from the database, and then write a xml file. The format of the xml file is as follows.

Mainchart.xml

500817132010.06.13 14 14:19balance3TRMM-DP 192010.06.16 14:19balance3TRMM-DP (123005)-D501108332010.06.15 16 16:23buyeurusd1.318221.316550000:08:00aaafff501191332010.06.15 152010.06.15 1512010.06.15 17:19selleurusd1.318191.318090000:28:00eee

Processing in the php file.

$file = "mainchart.xml"; / create the object of DOMDocument $dom=new DOMDocument ('1.0'); / / load the mainchart.xml file $dom- > load ($file); / / get the collection of record nodes $records = $dom- > getElementsByTagName (' record') / / traversing the collection of record nodes foreach ($records as $record) {/ / if the value of the record node's pono child node satisfies the condition, modify the value of the memo child node under the record node if ($record- > getElementsByTagName ('pono')-> item (0)-> nodeValue = = $_ GET [' id']) {$record- > getElementsByTagName ('memo')-> item (0)-> nodeValue = $_ GET [' content'] }} $dom- > save ('mainchart.xml')

$_ GET ['id'] and $_ GET [' content'] are parameters passed from ajax.

At this point, I believe you have a deeper understanding of "how php changes the value of xml nodes". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report