Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial php xml 正则表达式

php xml 正则表达式

Jun 23, 2016 pm 02:06 PM

接收到类似下面一个xml文件,想把文件的内容分成对应的数组 输出出来,应该怎么处理
比如:

我是个算命先生 的“我是个算命先生”应该是个字段
易之的“易之”应该是个字段
***中间的内容
7507424758 中的“7507424758”

  <?xml version="1.0" encoding="UTF-8" ?> - <entry xmlns="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/">  <id>http://api.douban.com/book/subject/10506822</id>   <title>我是个算命先生</title>   <category scheme="http://www.douban.com/2007#kind" term="http://www.douban.com/2007#book" /> - <author>  <name>易之</name>   </author>  <link href="http://api.douban.com/book/subject/10506822" rel="self" />   <link href="http://book.douban.com/subject/10506822/" rel="alternate" />   <link href="http://img3.douban.com/spic/s8993763.jpg" rel="image" />   <link href="http://m.douban.com/book/subject/10506822/" rel="mobile" />   <summary>《我是个算命先生》内容简介:算命这个行当,萌芽于先秦,发展于隋唐,泛滥于明清;汉代张良、三国诸葛亮、明代刘伯温,不同时期的代表人物,都在手相、面相、八字、八卦中辨认着人类的命运。祖爷,生于1902年,卒年不详,民国时期名震大江南北的算命群体“江相派”掌门人。《沪报》将他与袁树珊、韦千里、徐乐吾并称为“民国四大算命宗师”,所谓“南袁北韦东乐吾,三仙归来问祖爷”。祖爷15岁开始为人算命,每算必中,令人咋舌;而后叱咤江湖30多年,留下无数不可思议的神算传奇与悬念;乃至于中原大战之前,山西军阀阎锡山也三顾茅庐,终于求得祖爷一卦。祖爷总说,看的是面相,算的是八字,捕捉的是问卦人脸上不断闪烁的欲望:贪婪、虚荣、妒忌、恐惧、傲慢??人的命运,确实写在脸上。祖爷一生几乎从未失手,唯一没有算到的,却是他自己的命运;面对凄凉晚景,他认为是自己泄露了太多天机…… 翻开《我是个算命先生》,让一个82岁的算命老先生带您见识算命背后的古老智慧与江湖猫腻。 海报:</summary>   <db:attribute name="isbn10">7507424758</db:attribute>   <db:attribute name="isbn13">9787507424751</db:attribute>   <db:attribute name="title">我是个算命先生</db:attribute>   <db:attribute name="pages">245</db:attribute>   <db:attribute name="author">易之</db:attribute>   <db:attribute name="price">29.90元</db:attribute>   <db:attribute name="publisher">中国城市出版社</db:attribute>   <db:attribute name="binding">平装</db:attribute>   <db:attribute name="pubdate">2012-2</db:attribute>   <db:attribute name="author-intro">易之,男,山东即墨人。8岁接触道家学派,12岁跟随当地异人合玄师傅修习四柱,大学师从国内知名玄学教授段景莲。现为中华周易协会常务理事。</db:attribute>   <db:tag count="585" name="算命" />   <db:tag count="463" name="小说" />   <db:tag count="197" name="骗局" />   <db:tag count="137" name="社会分析" />   <db:tag count="129" name="黑道学" />   <db:tag count="112" name="社会" />   <db:tag count="106" name="文化" />   <db:tag count="89" name="中国" />   <gd:rating average="7.0" max="10" min="0" numRaters="971" />   </entry>
Copy after login


回复讨论(解决方案)

用xml dom更好

$s=<<(.+)
Copy after login

谢谢 jordan102,但是 请问下 那个

***** 之间内容也想要怎么办呢

]*+>((?:(?!\1).)++)      分组2

谢谢 jordan102,但是 请问下 那个

***** 之间内容也想要怎么办呢 本来就有啊,你运行一下就知道了。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

See all articles