增加 风神接口
parent
511212d59f
commit
2f48e3f31d
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AndroidTestResultsUserPreferences">
|
||||||
|
<option name="androidTestResultsTableState">
|
||||||
|
<map>
|
||||||
|
<entry key="-941396539">
|
||||||
|
<value>
|
||||||
|
<AndroidTestResultsTableState>
|
||||||
|
<option name="preferredColumnWidths">
|
||||||
|
<map>
|
||||||
|
<entry key="Duration" value="90" />
|
||||||
|
<entry key="Tests" value="360" />
|
||||||
|
<entry key="alps k62v1_3h" value="120" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</AndroidTestResultsTableState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="-531529726">
|
||||||
|
<value>
|
||||||
|
<AndroidTestResultsTableState>
|
||||||
|
<option name="preferredColumnWidths">
|
||||||
|
<map>
|
||||||
|
<entry key="Duration" value="90" />
|
||||||
|
<entry key="Pixel_2_API_33" value="120" />
|
||||||
|
<entry key="Tests" value="360" />
|
||||||
|
<entry key="alps k62v1_3h" value="120" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</AndroidTestResultsTableState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="1094103868">
|
||||||
|
<value>
|
||||||
|
<AndroidTestResultsTableState>
|
||||||
|
<option name="preferredColumnWidths">
|
||||||
|
<map>
|
||||||
|
<entry key="Duration" value="90" />
|
||||||
|
<entry key="Tests" value="360" />
|
||||||
|
<entry key="alps k62v1_3h" value="120" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</AndroidTestResultsTableState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,140 @@
|
|||||||
|
package com.example.writeepc;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.example.writeepc.been.MESInfo;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class ShuangqianActivity2Test extends TestCase {
|
||||||
|
|
||||||
|
|
||||||
|
public void test() {
|
||||||
|
String result = """
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<soap:Body>
|
||||||
|
<GetRFIDBindingInfoResponse xmlns="http://tempuri.org/">
|
||||||
|
<GetRFIDBindingInfoResult>
|
||||||
|
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Table" msdata:UseCurrentLocale="true">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||||
|
<xs:element name="Table">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="品牌" type="xs:string" minOccurs="0"/>
|
||||||
|
<xs:element name="规格" type="xs:string" minOccurs="0"/>
|
||||||
|
<xs:element name="花纹类型" type="xs:string" minOccurs="0"/>
|
||||||
|
<xs:element name="胎号" type="xs:string" minOccurs="0"/>
|
||||||
|
<xs:element name="DOT" type="xs:string" minOccurs="0"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:choice>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
|
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
|
||||||
|
<NewDataSet xmlns="">
|
||||||
|
<Table diffgr:id="Table1" msdata:rowOrder="0">
|
||||||
|
<品牌>123</品牌>
|
||||||
|
<规格>1234</规格>
|
||||||
|
<花纹类型>1235</花纹类型>
|
||||||
|
<胎号>1236</胎号>
|
||||||
|
<DOT>1236</DOT>
|
||||||
|
</Table>
|
||||||
|
</NewDataSet>
|
||||||
|
</diffgr:diffgram>
|
||||||
|
</GetRFIDBindingInfoResult>
|
||||||
|
</GetRFIDBindingInfoResponse>
|
||||||
|
</soap:Body>
|
||||||
|
</soap:Envelope>
|
||||||
|
""";
|
||||||
|
|
||||||
|
String regex = "<Table .*\">";
|
||||||
|
Pattern pattern = Pattern.compile(regex);
|
||||||
|
Matcher matcher = pattern.matcher(result);
|
||||||
|
if (!matcher.find()) {
|
||||||
|
System.out.println("未找到匹配的内容");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String matched = matcher.group();// 匹配内容
|
||||||
|
int beginIndex = matcher.start() + matched.length();
|
||||||
|
int endIndex = result.indexOf("</Table>");
|
||||||
|
Log.e("TAG", "test1:" + beginIndex);
|
||||||
|
Log.e("TAG", "test2:" + endIndex);
|
||||||
|
if (beginIndex >= endIndex) {
|
||||||
|
System.out.println("未找到匹配的内容");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
result = result.substring(beginIndex, endIndex);
|
||||||
|
System.out.println("截取内容:" + result);
|
||||||
|
// <品牌>风神</品牌><规格>10.00R20</规格><花纹类型>AGC08</花纹类型)<胎号>ZB250901399</胎号><DOT>3625</DOT>
|
||||||
|
|
||||||
|
|
||||||
|
String[] str=new String[]{"品牌","规格","花纹类型","胎号","DOT"};
|
||||||
|
for (String s : str) {
|
||||||
|
String tag = "<" + s + ">";
|
||||||
|
System.out.println("-"+result.substring(result.indexOf(tag) + tag.length(), result.indexOf("</"+s+">"))+"-");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* InputStream inputStream = new StringBufferInputStream(result);
|
||||||
|
XmlPullParser parser = Xml.newPullParser();
|
||||||
|
parser.setInput(inputStream, "utf-8"); // 设置输入流和编码
|
||||||
|
int eventType = parser.getEventType();
|
||||||
|
boolean isInTable = false; // 是否进入<Table>节点
|
||||||
|
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||||
|
String tagName = parser.getName();
|
||||||
|
System.out.println("tab name :"+tagName);
|
||||||
|
switch (eventType) {
|
||||||
|
case XmlPullParser.START_TAG:
|
||||||
|
// 找到<Table>节点,初始化数据对象
|
||||||
|
if ("Table".equals(tagName)) {
|
||||||
|
isInTable = true;
|
||||||
|
|
||||||
|
} else if (isInTable) {
|
||||||
|
switch (tagName) {
|
||||||
|
case "品牌":
|
||||||
|
String trim = parser.nextText().trim();
|
||||||
|
System.out.println(trim);
|
||||||
|
break;
|
||||||
|
case "规格":
|
||||||
|
String trim2 = parser.nextText().trim();
|
||||||
|
System.out.println(trim2);
|
||||||
|
break;
|
||||||
|
case "花纹类型":
|
||||||
|
String trim3 = parser.nextText().trim();
|
||||||
|
System.out.println(trim3);
|
||||||
|
break;
|
||||||
|
case "胎号":
|
||||||
|
String trim4 = parser.nextText().trim();
|
||||||
|
System.out.println(trim4);
|
||||||
|
break;
|
||||||
|
case "DOT":
|
||||||
|
String trim5 = parser.nextText().trim();
|
||||||
|
System.out.println(trim5);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XmlPullParser.END_TAG:
|
||||||
|
// 退出<Table>节点
|
||||||
|
if ("Table".equals(tagName)) {
|
||||||
|
isInTable = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
eventType = parser.next(); // 解析下一个事件
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue