| | |
| | | package com.genersoft.iot.vmp.gb28181.utils;
|
| | |
|
| | | import java.io.StringReader;
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import com.alibaba.fastjson.JSONArray;
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | |
|
| | | import org.dom4j.Attribute;
|
| | | import org.dom4j.Document;
|
| | | import org.dom4j.DocumentException;
|
| | |
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.util.StringUtils;
|
| | |
|
| | | import javax.sip.RequestEvent;
|
| | | import javax.sip.message.Request;
|
| | | import java.io.ByteArrayInputStream;
|
| | | import java.io.StringReader;
|
| | | import java.util.*;
|
| | |
|
| | | /**
|
| | | * 基于dom4j的工具包
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | public static Element getRootElement(RequestEvent evt) throws DocumentException {
|
| | |
|
| | | return getRootElement(evt, "gb2312");
|
| | | }
|
| | |
|
| | | public static Element getRootElement(RequestEvent evt, String charset) throws DocumentException {
|
| | | Request request = evt.getRequest();
|
| | | return getRootElement(request.getRawContent(), charset);
|
| | | }
|
| | |
|
| | | public static Element getRootElement(byte[] content, String charset) throws DocumentException {
|
| | | if (charset == null) {
|
| | | charset = "gb2312";
|
| | | }
|
| | | SAXReader reader = new SAXReader();
|
| | | reader.setEncoding(charset);
|
| | | Document xml = reader.read(new ByteArrayInputStream(content));
|
| | | return xml.getRootElement();
|
| | | }
|
| | | }
|