thinkphp解析xml格式或json

浏览:3984 发布日期:2016/10/12 分类:求助交流 关键字: thinkphp xml json 解析xml 解析json php解析xml
最近在网址找了很多,有些能解决,但不是很好,我想对固定的xml进行规范的解析,统筹写一个类,但是我不太会,望大神解答

xml格式如下:
xml:
<OPHIUX>
<HEAD>
<SERVICE_NAME>getDoctorInfo</SERVICE_NAME>
<PARAM>
<HOSPITAL_CODE>111</HOSPITAL_CODE>
<OCCASION>all</OCCASION>
<RESULT>1</RESULT>
<DOCTOR_CODE></DOCTOR_CODE>
</PARAM>
<R_FORM>返回数据格式(JSON/xml)</R_FORM>
<ISSUCCESS>true</ISSUCCESS>
<RESULTCODE>100</RESULTCODE>
<MESS_COUNT>1</MESS_COUNT>
</HEAD>
<MESSAGE>
<DATA>
<HOSPITAL_CODE>111</HOSPITAL_CODE>
<DEPT_CODE>abc</DEPT_CODE>
<DEPT_NAME>骨科</DEPT_NAME>
<DOCTOR_CODE>aaa</DOCTOR_CODE>
<DOCTOR_NAME>某某</DOCTOR_NAME>
<DOC_BRIEF_INTRODUCTION>
知名医生,精于各种接骨手法
</DOC_BRIEF_INTRODUCTION>
<DOCTOR_PINYIN>moumou</DOCTOR_PINYIN>
<SEX>男</SEX>
<TEL>13330333333</TEL>
<BIRTHDAY>1983-08-31</BIRTHDAY>
<EMAIL>kkk@163.com</EMAIL>
<ID_CARD_NUMBER>511</ID_CARD_NUMBER>
<TECHNICAL_title>教授</TECHNICAL_title>
<PICTURE>moumoumou.gif</PICTURE>
<OCCASION>reg</OCCASION>
<DISPLAY_ORDER>22</DISPLAY_ORDER>
</DATA>
.......多个<DATA>医生信息属性</DATA>
</MESSAGE>
</OPHIUX>


json格式如下:
JSON:
{
"OPHIUX":
{
"HEAD":
{
"SERVICE_NAME": "getDoctorInfo",
"PARAM ":
{
"HOSPITAL_CODE":"111",
"OCCASION":"all",
"RESULT":"1",
"DOCTOR_CODE":""
},
"R_FORM": "返回数据格式(JSON/xml)",
"ISSUCCESS":"true",
"RESULTCODE":"100",
"MESS_COUNT":"1"
},
"DATA":
[
{
"HOSPITAL_CODE":"111",
"DEPT_CODE":"abc",
"DEPT_NAME":"骨科",
"DOCTOR_CODE":"aaa",
"DOCTOR_NAME":"某某",
"DOC_BRIEF_INTRODUCTION":"知名医生,精于各种接骨手法",
"DOCTOR_PINYIN":"moumoumou",
"SEX":"男",
"TEL":"13330333333",
"BIRTHDAY":"1983-08-31",
"EMAIL":"kkk@163.com",
"ID_CARD_NUMBER":"511211194608",
"TECHNICAL_title":"教授",
"PICTURE":"moumoumou.gif",
"OCCASION":"reg"
},
......多个{医生信息属性}
]
}
}
如何获取数据这一段,头部<HEAD>不需要, 需要的是<DATA>这一段数据,目前没有头绪,望接待
最佳答案
评论( 相关
后面还有条评论,点击查看>>