/*
 *      Copyright (c) 2018-2028, DreamLu All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: DreamLu 卢春梦 (596392912@qq.com)
 */
package com.ann.demo.utils;

import org.springframework.lang.Nullable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;

/**
 * xpath解析xml
 *
 * <pre>
 *     文档地址：
 *     http://www.w3school.com.cn/xpath/index.asp
 * </pre>
 *
 * @author L.cm
 */
public class XmlUtil {
	private final XPath path;
	private final Document doc;

	private XmlUtil(InputSource inputSource) throws ParserConfigurationException, SAXException, IOException {
		DocumentBuilderFactory dbf = getDocumentBuilderFactory();
		DocumentBuilder db = dbf.newDocumentBuilder();
		doc = db.parse(inputSource);
		path = getXPathFactory().newXPath();
	}

	/**
	 * 创建工具类
	 *
	 * @param inputSource inputSource
	 * @return XmlUtil
	 */
	private static XmlUtil create(InputSource inputSource) {
		try {
			return new XmlUtil(inputSource);
		} catch (ParserConfigurationException | SAXException | IOException e) {
			e.printStackTrace();
			return null;
		}
	}

	/**
	 * 转换工具类
	 *
	 * @param inputStream inputStream
	 * @return XmlUtil
	 */
	public static XmlUtil of(InputStream inputStream) {
		InputSource inputSource = new InputSource(inputStream);
		return create(inputSource);
	}

	/**
	 * 转换工具类
	 *
	 * @param xmlStr xmlStr
	 * @return XmlUtil
	 */
	public static XmlUtil of(String xmlStr) {
		StringReader sr = new StringReader(xmlStr.trim());
		InputSource inputSource = new InputSource(sr);
		XmlUtil xmlUtil = create(inputSource);
		//IoUtil.closeQuietly(sr);
		return xmlUtil;
	}

	/**
	 * 转换路径
	 *
	 * @param expression 表达式
	 * @param item       实体
	 * @param returnType 返回类型
	 * @return Object
	 */
	private Object evalXPath(String expression, @Nullable Object item, QName returnType) {
		item = null == item ? doc : item;
		try {
			return path.evaluate(expression, item, returnType);
		} catch (XPathExpressionException e) {
			e.printStackTrace();
			return null;
		}
	}

	/**
	 * 获取String
	 *
	 * @param expression 路径
	 * @return {String}
	 */
	public String getString(String expression) {
		return (String) evalXPath(expression, null, XPathConstants.STRING);
	}

	/**
	 * 获取Boolean
	 *
	 * @param expression 路径
	 * @return {String}
	 */
	public Boolean getBoolean(String expression) {
		return (Boolean) evalXPath(expression, null, XPathConstants.BOOLEAN);
	}

	/**
	 * 获取Number
	 *
	 * @param expression 路径
	 * @return {Number}
	 */
	public Number getNumber(String expression) {
		return (Number) evalXPath(expression, null, XPathConstants.NUMBER);
	}

	/**
	 * 获取某个节点
	 *
	 * @param expression 路径
	 * @return {Node}
	 */
	public Node getNode(String expression) {
		return (Node) evalXPath(expression, null, XPathConstants.NODE);
	}

	/**
	 * 获取子节点
	 *
	 * @param expression 路径
	 * @return NodeList
	 */
	public NodeList getNodeList(String expression) {
		return (NodeList) evalXPath(expression, null, XPathConstants.NODESET);
	}


	/**
	 * 获取String
	 *
	 * @param node       节点
	 * @param expression 相对于node的路径
	 * @return {String}
	 */
	public String getString(Object node, String expression) {
		return (String) evalXPath(expression, node, XPathConstants.STRING);
	}

	/**
	 * 获取
	 *
	 * @param node       节点
	 * @param expression 相对于node的路径
	 * @return {String}
	 */
	public Boolean getBoolean(Object node, String expression) {
		return (Boolean) evalXPath(expression, node, XPathConstants.BOOLEAN);
	}

	/**
	 * 获取
	 *
	 * @param node       节点
	 * @param expression 相对于node的路径
	 * @return {Number}
	 */
	public Number getNumber(Object node, String expression) {
		return (Number) evalXPath(expression, node, XPathConstants.NUMBER);
	}

	/**
	 * 获取某个节点
	 *
	 * @param node       节点
	 * @param expression 路径
	 * @return {Node}
	 */
	public Node getNode(Object node, String expression) {
		return (Node) evalXPath(expression, node, XPathConstants.NODE);
	}

	/**
	 * 获取子节点
	 *
	 * @param node       节点
	 * @param expression 相对于node的路径
	 * @return NodeList
	 */
	public NodeList getNodeList(Object node, String expression) {
		return (NodeList) evalXPath(expression, node, XPathConstants.NODESET);
	}

	/**
	 * 针对没有嵌套节点的简单处理
	 *
	 * @return map集合
	 */
	public Map<String, String> toMap() {
		Element root = doc.getDocumentElement();
		Map<String, String> params = new HashMap<>(16);

		// 将节点封装成map形式
		NodeList list = root.getChildNodes();
		for (int i = 0; i < list.getLength(); i++) {
			Node node = list.item(i);
			if (node instanceof Element) {
				params.put(node.getNodeName(), node.getTextContent());
			}
		}
		return params;
	}

	private static volatile boolean preventedXXE = false;

	private static DocumentBuilderFactory getDocumentBuilderFactory() throws ParserConfigurationException {
		DocumentBuilderFactory dbf = XmlHelperHolder.documentBuilderFactory;
		if (!preventedXXE) {
			preventXXE(dbf);
		}
		return dbf;
	}

	/**
	 * preventXXE
	 *
	 * @param dbf
	 * @throws ParserConfigurationException
	 */
	private static void preventXXE(DocumentBuilderFactory dbf) throws ParserConfigurationException {
		// This is the PRIMARY defense. If DTDs (doctypes) are disallowed, almost all XML entity attacks are prevented
		// Xerces 2 only - http://xerces.apache.org/xerces2-j/features.html#disallow-doctype-decl
		dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);

		// If you can't completely disable DTDs, then at least do the following:
		// Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-general-entities
		// Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-general-entities

		// JDK7+ - http://xml.org/sax/features/external-general-entities
		dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);

		// Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-parameter-entities
		// Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-parameter-entities

		// JDK7+ - http://xml.org/sax/features/external-parameter-entities
		dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);

		// Disable external DTDs as well
		dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

		// and these as well, per Timothy Morgan's 2014 paper: "XML Schema, DTD, and Entity Attacks"
		dbf.setXIncludeAware(false);
		dbf.setExpandEntityReferences(false);
		preventedXXE = true;
	}

	private static XPathFactory getXPathFactory() {
		return XmlHelperHolder.xPathFactory;
	}

	/**
	 * 内部类单例
	 */
	private static class XmlHelperHolder {
		private static DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
		private static XPathFactory xPathFactory = XPathFactory.newInstance();
	}


	public static void main(String[] args) {
		XmlUtil  a=XmlUtil.of("<POOR_IN200901UV\n" +
				"    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
				"    xmlns=\"urn:hl7-org:v3\" ITSVersion=\"XML_1.0\" xsi:schemaLocation=\"urn:hl7-org:v3 ../../Schemas/POOR_IN200901UV20.xsd\">\n" +
				"    <id extension=\"JHIPBS303\"></id>\n" +
				"    <creationTime value=\"2023-05-17 10:21:55\"></creationTime>\n" +
				"    <interactionId root=\"\" extension=\"POOR_IN200901UV20\"></interactionId>\n" +
				"    <processingCode code=\"P\"></processingCode>\n" +
				"    <processingModeCode code=\"T\"></processingModeCode>\n" +
				"    <acceptAckCode code=\"NE\"></acceptAckCode>\n" +
				"    <receiver typeCode=\"RCV\">\n" +
				"        <device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
				"            <id>\n" +
				"                <item root=\"1.2.156.112698.1.1.1\" extension=\"HIS\"></item>\n" +
				"            </id>\n" +
				"        </device>\n" +
				"    </receiver>\n" +
				"    <sender typeCode=\"SND\">\n" +
				"        <device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
				"            <id>\n" +
				"                <item root=\"1.2.156.112698.2.1.1\" extension=\"放射\"></item>\n" +
				"            </id>\n" +
				"        </device>\n" +
				"    </sender>\n" +
				"    <controlActProcess classCode=\"CACT\" moodCode=\"EVN\">\n" +
				"        <code code=\"new\"></code>\n" +
				"        <subject typeCode=\"SUBJ\" xsi:nil=\"false\">\n" +
				"            <placerGroup classCode=\"GROUPER\" moodCode=\"RQO\">\n" +
				"                <subject>\n" +
				"                    <patient classCode=\"PAT\">\n" +
				"                        <id>\n" +
				"                            <item root=\"1.2.156.112698.1.1.2.1.5\" extension=\"02\"></item>\n" +
				"                            <item root=\"1.2.156.112698.1.1.2.1.6\" extension=\"000757309000\"></item>\n" +
				"                            <item root=\"1.2.156.112698.1.1.2.1.21\" extension=\"1659561\"></item>\n" +
				"                            <item root=\"1.2.156.112698.1.1.2.1.23\" extension=\"1659561\"></item>\n" +
				"                            <item root=\"1.2.156.112698.1.1.2.1.22\" extension=\"1\"></item>\n" +
				"                        </id>\n" +
				"                        <addr xsi:type=\"BAG_AD\">\n" +
				"                            <item use=\"TMP\">\n" +
				"                                <part type=\"BNR\" value=\"脊柱微创外科病房\" code=\"1120102\" codeSystem=\"1.2.156.112698.1.1.1.4.7\"></part>\n" +
				"                                <part type=\"CAR\" value=\"1043\"></part>\n" +
				"                            </item>\n" +
				"                        </addr>\n" +
				"                        <patientPerson classCode=\"PSN\">\n" +
				"                            <id>\n" +
				"                                <item extension=\"440824195812258314\" root=\"1.2.156.112698.1.1.2.1.8\"></item>\n" +
				"                                <item extension=\"\" root=\"1.2.156.112698.1.1.2.1.4\"></item>\n" +
				"                            </id>\n" +
				"                            <name xsi:type=\"BAG_EN\">\n" +
				"                                <item>\n" +
				"                                    <part value=\"杨茂青\"></part>\n" +
				"                                </item>\n" +
				"                            </name>\n" +
				"                            <telecom xsi:type=\"BAG_TEL\">\n" +
				"                                <item value=\"13413637636\"></item>\n" +
				"                            </telecom>\n" +
				"                            <administrativeGenderCode code=\"1\" codeSystem=\"1.2.156.112698.1.1.1.2.1\"></administrativeGenderCode>\n" +
				"                            <birthTime value=\"19581225000000\">\n" +
				"                                <originalText value=\"64岁\"></originalText>\n" +
				"                            </birthTime>\n" +
				"                            <addr xsi:type=\"BAG_AD\">\n" +
				"                                <item use=\"H\">\n" +
				"                                    <part type=\"AL\" value=\"贸易城新城路三横二号\"></part>\n" +
				"                                </item>\n" +
				"                            </addr>\n" +
				"                            <maritalStatusCode code=\"2\" codeSystem=\"1.2.156.112698.1.1.1.2.2\"></maritalStatusCode>\n" +
				"                            <ethnicGroupCode>\n" +
				"                                <item code=\"\" codeSystem=\"1.2.156.112698.1.1.1.2.3\"></item>\n" +
				"                            </ethnicGroupCode>\n" +
				"                            <asEmployee classCode=\"EMP\">\n" +
				"                                <occupationCode code=\"90\" codeSystem=\"1.2.156.112698.1.1.1.2.5\">\n" +
				"                                    <displayName value=\"其他\"></displayName>\n" +
				"                                </occupationCode>\n" +
				"                                <employerOrganization determinerCode=\"INSTANCE\" classCode=\"ORG\">\n" +
				"                                    <name xsi:type=\"BAG_EN\">\n" +
				"                                        <item>\n" +
				"                                            <part value=\"\"></part>\n" +
				"                                        </item>\n" +
				"                                    </name>\n" +
				"                                    <contactParty classCode=\"CON\" xsi:nil=\"true\"></contactParty>\n" +
				"                                </employerOrganization>\n" +
				"                            </asEmployee>\n" +
				"                            <asCitizen>\n" +
				"                                <politicalNation>\n" +
				"                                    <code code=\"\" codeSystem=\"1.2.156.112698.1.1.1.2.4\">\n" +
				"                                        <displayName value=\"\"></displayName>\n" +
				"                                    </code>\n" +
				"                                </politicalNation>\n" +
				"                            </asCitizen>\n" +
				"                            <contactParty classCode=\"CON\">\n" +
				"                                <telecom xsi:type=\"BAG_TEL\">\n" +
				"                                    <item use=\"MC\" value=\"\" capabilities=\"voice\"></item>\n" +
				"                                </telecom>\n" +
				"                                <contactPerson>\n" +
				"                                    <name xsi:type=\"BAG_EN\">\n" +
				"                                        <item use=\"IDE\">\n" +
				"                                            <part value=\"\"></part>\n" +
				"                                        </item>\n" +
				"                                    </name>\n" +
				"                                </contactPerson>\n" +
				"                            </contactParty>\n" +
				"                            <text value=\"双上肢麻痛1月余\"></text>\n" +
				"                        </patientPerson>\n" +
				"                        <providerOrganization classCode=\"ORG\" determinerCode=\"INSTANCE\">\n" +
				"                            <id>\n" +
				"                                <item extension=\"1120102\" root=\"1.2.156.112698.1.1.1.4.1\"></item>\n" +
				"                            </id>\n" +
				"                            <name xsi:type=\"BAG_EN\">\n" +
				"                                <item>\n" +
				"                                    <part value=\"脊柱微创外科病房\"></part>\n" +
				"                                </item>\n" +
				"                            </name>\n" +
				"                            <asOrganizationPartOf classCode=\"PART\">\n" +
				"                                <wholeOrganization determinerCode=\"INSTANCE\" classCode=\"ORG\">\n" +
				"                                    <id>\n" +
				"                                        <item extension=\"12440000455858169P\"></item>\n" +
				"                                    </id>\n" +
				"                                    <name xsi:type=\"BAG_EN\">\n" +
				"                                        <item>\n" +
				"                                            <part value=\"广东医科大学附属医院\"></part>\n" +
				"                                        </item>\n" +
				"                                    </name>\n" +
				"                                </wholeOrganization>\n" +
				"                            </asOrganizationPartOf>\n" +
				"                        </providerOrganization>\n" +
				"                    </patient>\n" +
				"                </subject>\n" +
				"                <author>\n" +
				"                    <time value=\"20230516171700\"></time>\n" +
				"                    <assignedEntity classCode=\"ASSIGNED\">\n" +
				"                        <id>\n" +
				"                            <item extension=\"06616\" root=\"1.2.156.112698.1.1.1.4.2\"></item>\n" +
				"                        </id>\n" +
				"                        <assignedPerson determinerCode=\"INSTANCE\" classCode=\"PSN\">\n" +
				"                            <name xsi:type=\"BAG_EN\">\n" +
				"                                <item>\n" +
				"                                    <part value=\"梁振\"></part>\n" +
				"                                </item>\n" +
				"                            </name>\n" +
				"                        </assignedPerson>\n" +
				"                        <representedOrganization determinerCode=\"INSTANCE\" classCode=\"ORG\">\n" +
				"                            <id>\n" +
				"                                <item extension=\"1120102\" root=\"1.2.156.112698.1.1.1.4.10\"></item>\n" +
				"                            </id>\n" +
				"                            <name xsi:type=\"BAG_EN\">\n" +
				"                                <item>\n" +
				"                                    <part value=\"脊柱微创外科病房\"></part>\n" +
				"                                </item>\n" +
				"                            </name>\n" +
				"                        </representedOrganization>\n" +
				"                    </assignedEntity>\n" +
				"                </author>\n" +
				"                <verifier typeCode=\"VRF\">\n" +
				"                    <time value=\"2023-05-17 10:21:55\"></time>\n" +
				"                    <assignedEntity classCode=\"ASSIGNED\">\n" +
				"                        <id>\n" +
				"                            <item extension=\"\" root=\"1.2.156.112698.1.1.1.4.2\"></item>\n" +
				"                        </id>\n" +
				"                        <assignedPerson determinerCode=\"INSTANCE\" classCode=\"PSN\">\n" +
				"                            <name xsi:type=\"BAG_EN\">\n" +
				"                                <item>\n" +
				"                                    <part value=\"吴丽梅\"></part>\n" +
				"                                </item>\n" +
				"                            </name>\n" +
				"                        </assignedPerson>\n" +
				"                    </assignedEntity>\n" +
				"                </verifier>\n" +
				"                <component2>\n" +
				"                    <observationRequest classCode=\"OBS\" moodCode=\"RQO\">\n" +
				"                        <id>\n" +
				"                            <item extension=\"118300424\"></item>\n" +
				"                        </id>\n" +
				"                        <code code=\"2\" codeSystem=\"1.2.156.112698.1.1.1.4.5\">\n" +
				"                            <displayName value=\"检查类\"></displayName>\n" +
				"                        </code>\n" +
				"                        <text value=\"\"></text>\n" +
				"                        <statusCode code=\"E\"></statusCode>\n" +
				"                        <effectiveTime xsi:type=\"IVL_TS\">\n" +
				"                            <any value=\"20230516171700\"></any>\n" +
				"                        </effectiveTime>\n" +
				"                        <addr xsi:type=\"BAG_AD\">\n" +
				"                            <item use=\"H\">\n" +
				"                                <part type=\"AL\" value=\"12楼\"></part>\n" +
				"                            </item>\n" +
				"                        </addr>\n" +
				"                        <specimen typeCode=\"SPC\">\n" +
				"                            <specimen classCode=\"SPEC\">\n" +
				"                                <id extension=\"\"></id>\n" +
				"                                <code code=\"\" codeSystem=\"1.2.156.112698.1.1.1.3.5\"></code>\n" +
				"                                <subjectOf1 typeCode=\"SBJ\">\n" +
				"                                    <specimenCollectionProcess moodCode=\"EVN\" classCode=\"SPECCOLLECT\">\n" +
				"                                        <code></code>\n" +
				"                                        <text value=\"\"></text>\n" +
				"                                    </specimenCollectionProcess>\n" +
				"                                </subjectOf1>\n" +
				"                            </specimen>\n" +
				"                        </specimen>\n" +
				"                        <location typeCode=\"LOC\">\n" +
				"                            <time>\n" +
				"                                <any value=\"\"></any>\n" +
				"                            </time>\n" +
				"                            <serviceDeliveryLocation classCode=\"SDLOC\">\n" +
				"                                <serviceProviderOrganization determinerCode=\"INSTANCE\" classCode=\"ORG\">\n" +
				"                                    <id>\n" +
				"                                        <item extension=\"1120101\" root=\"1.2.156.112698.1.1.1.4.1\"></item>\n" +
				"                                    </id>\n" +
				"                                    <name xsi:type=\"BAG_EN\">\n" +
				"                                        <item>\n" +
				"                                            <part value=\"关节外科（运动医学中心）病房\"></part>\n" +
				"                                        </item>\n" +
				"                                    </name>\n" +
				"                                </serviceProviderOrganization>\n" +
				"                            </serviceDeliveryLocation>\n" +
				"                        </location>\n" +
				"                        <component2>\n" +
				"                            <observationRequest classCode=\"OBS\">\n" +
				"                                <id>\n" +
				"                                    <item extension=\"118300424\"></item>\n" +
				"                                </id>\n" +
				"                                <code code=\"26627\" codeSystem=\"1.2.156.112698.1.1.1.4.11\">\n" +
				"                                    <displayName value=\"骨密度测定\"></displayName>\n" +
				"                                </code>\n" +
				"                                <text value=\"\"></text>\n" +
				"                                <statusCode value=\"0\"></statusCode>\n" +
				"                                <effectiveTime xsi:type=\"NO\" validTimeLow=\"\" validTimeHigh=\"\">\n" +
				"                                    <code code=\"ONCE\" codeSystem=\"1.2.156.112698.1.1.1.4.44\">\n" +
				"                                        <displayName value=\"ONCE\"></displayName>\n" +
				"                                    </code>\n" +
				"                                </effectiveTime>\n" +
				"                                <methodCode>\n" +
				"                                    <item code=\"26627\" codeSystem=\"1.2.156.112698.1.1.1.4.41\">\n" +
				"                                        <displayName value=\"骨密度测定\"></displayName>\n" +
				"                                    </item>\n" +
				"                                </methodCode>\n" +
				"                                <targetSiteCode>\n" +
				"                                    <item code=\"\" codeSystem=\"1.2.156.112698.1.1.1.4.8\">\n" +
				"                                        <displayName value=\"\"></displayName>\n" +
				"                                    </item>\n" +
				"                                </targetSiteCode>\n" +
				"                                <pertinentInformation typeCode=\"PERT\" contextConductionInd=\"false\">\n" +
				"                                    <observation classCode=\"OBS\" moodCode=\"INT\">\n" +
				"                                        <code code=\"0102\" codeSystem=\"1.2.156.112698.1.1.1.4.15\">\n" +
				"                                            <displayName value=\"收费状态标识\"></displayName>\n" +
				"                                        </code>\n" +
				"                                        <value xsi:type=\"ST\" value=\"1\"></value>\n" +
				"                                    </observation>\n" +
				"                                </pertinentInformation>\n" +
				"                                <pertinentInformation typeCode=\"PERT\" contextConductionInd=\"false\">\n" +
				"                                    <observation classCode=\"OBS\" moodCode=\"INT\">\n" +
				"                                        <code code=\"0103\" codeSystem=\"1.2.156.112698.1.1.1.4.15\">\n" +
				"                                            <displayName value=\"费用金额\"></displayName>\n" +
				"                                        </code>\n" +
				"                                        <value xsi:type=\"ST\" value=\"192.5\"></value>\n" +
				"                                    </observation>\n" +
				"                                </pertinentInformation>\n" +
				"                                <pertinentInformation typeCode=\"PERT\" contextConductionInd=\"false\">\n" +
				"                                    <observation classCode=\"OBS\" moodCode=\"INT\">\n" +
				"                                        <code code=\"0104\" codeSystem=\"1.2.156.112698.1.1.1.4.16\">\n" +
				"                                            <displayName value=\"病理检验标志\"></displayName>\n" +
				"                                        </code>\n" +
				"                                        <value xsi:type=\"BL01\" value=\"0\"></value>\n" +
				"                                    </observation>\n" +
				"                                </pertinentInformation>\n" +
				"                                <pertinentInformation typeCode=\"PERT\" contextConductionInd=\"false\">\n" +
				"                                    <observation classCode=\"OBS\" moodCode=\"INT\">\n" +
				"                                        <code code=\"0105\" codeSystem=\"1.2.156.112698.1.1.1.4.17\">\n" +
				"                                            <displayName value=\"送检标本\"></displayName>\n" +
				"                                        </code>\n" +
				"                                        <value xsi:type=\"BL02\" value=\"0\"></value>\n" +
				"                                    </observation>\n" +
				"                                </pertinentInformation>\n" +
				"                                <ReceiptNo value=\"\"></ReceiptNo>\n" +
				"                                <AccessionNo value=\"OT20230517008\"></AccessionNo>\n" +
				"                            </observationRequest>\n" +
				"                        </component2>\n" +
				"                        <subjectOf6 contextConductionInd=\"false\" xsi:nil=\"false\">\n" +
				"                            <seperatableInd value=\"false\"></seperatableInd>\n" +
				"                            <annotation>\n" +
				"                                <text value=\"\"></text>\n" +
				"                                <statusCode code=\"completed\"></statusCode>\n" +
				"                                <author>\n" +
				"                                    <assignedEntity classCode=\"ASSIGNED\" value=\"确认诊断\"></assignedEntity>\n" +
				"                                </author>\n" +
				"                            </annotation>\n" +
				"                        </subjectOf6>\n" +
				"                        <AccessionNo value=\"OT20230517008\"></AccessionNo>\n" +
				"                    </observationRequest>\n" +
				"                </component2>\n" +
				"            </placerGroup>\n" +
				"        </subject>\n" +
				"    </controlActProcess>\n" +
				"</POOR_IN200901UV>");
		XPath path = a.path;
		System.out.println(path);
		Node node = a.getNode("/POOR_IN200901UV/controlActProcess/subject/placerGroup/component2/observationRequest/component2/observationRequest/AccessionNo/@value");
		String textContent = node.getTextContent();
		String s = node.toString();
		System.out.println(node);
	}

}
