- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
代码:
package com.parse;
import org.w3c.dom.*;
import javax.xml.xpath.*;
import javax.xml.parsers.*;
import java.io.IOException;
import org.xml.sax.SAXException;
public class XpathDemoOld {
public static void main(String[] args)
throws ParserConfigurationException, SAXException,
IOException, XPathExpressionException {
DocumentBuilderFactory domFactory =
DocumentBuilderFactory.newInstance();
domFactory.setNamespaceAware(true);
DocumentBuilder builder = domFactory.newDocumentBuilder();
Document doc = builder.parse("xml.xml");
XPath xpath = XPathFactory.newInstance().newXPath();
// XPath Query for showing all nodes value
XPathExpression expr = xpath.compile("/QDTM_IN300301QD/controlActEvent/subject/subject/testCodeIdentifier/coveredPartyOf/financialTransactionEvent/subjectOf/annotation/code[@code='CPTCODE']/following-sibling::text/text()");
Object result = expr.evaluate(doc, XPathConstants.NODESET);
NodeList nodes = (NodeList) result;
System.out.println("Length --- " + nodes.getLength());
for (int i = 0; i < nodes.getLength(); i++) {
System.out.println("Node Value--->" + nodes.item(i).getNodeValue());
}
}
}
XML:
<?xml version="1.0" encoding="UTF-8"?>
<QDTM_IN300301QD ITSVersion="XML_1.0" xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 QDTM_IN300301QD.xsd ">
<id assigningAuthorityName="TEST" extension="6399Z"/>
<creationTime value="20111111121213" />
<responseModeCode code="I"/>
<versionCode code="V3-2010-12-Q2"/>
<interactionId extension="QDTM_IN300301QD"/>
<profileId extension="TBD"/>
<processingCode code="P"/>
<processingModeCode code="T"/>
<acceptAckCode code="NE"/>
<receiver typeCode="RCV">
<realmCode code="QD" />
<device classCode="DEV" determinerCode="INSTANCE" >
<realmCode code="QD" />
<id assigningAuthorityName="RECEIVERID" extension="TESTCENTER" /> <!-- These are identifiers for the recieving application and would be picked from the request message -->
</device>
</receiver>
<sender typeCode="SND">
<realmCode code="QD" />
<device classCode="DEV" determinerCode="INSTANCE" >
<realmCode code="QD" />
<id assigningAuthorityName="SENDERID" extension="QTIM" /> <!-- These are identifiers for the sending application and can be picked from the recieving section of the request message -->
</device>
</sender>
<controlActEvent classCode="CACT" moodCode="EVN">
<id assigningAuthorityName="TESTMESSAGEID" extension="6399Z" />
<code code="TBD">
</code>
<statusCode code="Active"/>
<subject contextConductionInd="true">
<registrationEvent classCode="REG" moodCode="EVN">
<realmCode code="QD" />
<statusCode code="Active"/>
<subject contextControlCode="AN" typeCode="SBJ">
<realmCode code="QD" />
<testCodeIdentifier classCode="ROL">
<id assigningAuthorityName="PRMKEY" extension="SJC6399Z"/> <!-- This is a unique key in case of JDOS information. Might not be needed in case of FD. If it is decided that this is not required for FD then this can be removed -->
<playingTestCodeDetails classCode="ENT" determinerCode="INSTANCE">
<realmCode code="QD" />
<id assigningAuthorityName="PRMORDCODE" extension="6399Z" /><!--This is the primary order code for the test. Would be NTC in case of a Master-->
<code code="6399Z" codeSystemName="QTIM" >
<originalText><![CDATA[Complete Blood Count]]></originalText>
<originalText><![CDATA[Blood Cells]]></originalText>
</code>
<statusCode code="Active"/>
<testCodeHasMember classCode="MBR" negationInd="true" >
<subjectOf typeCode="SBJ">
<annotation classCode="ACT" moodCode="EVN" >
<realmCode code="QD" />
<code code="INCLUDESHTMLENABLED"></code>
<text><![CDATA[WBC, RBC, Hemoglobin, Hematocrit, MCV, MCH, MCHC, RDW, Platelet Count, MPV and Differential (Absolute and Percent - Neutrophils, Lymphocytes, Monocytes, Eosinophils, and Basophils) <br />
If abnormal cells are noted on a manual review of the peripheral blood smear or if the automated differential information meets specific criteria, a full manual differential will be performed.]]></text> <!-- Includes information is being passed here -->
<statusCode code="Updated"/><!-- This flag would indicate if this field has been updated or not -->
</annotation>
</subjectOf>
</testCodeHasMember>
</playingTestCodeDetails>
<subjectOf typeCode="SBJ">
<realmCode code="QD" />
<order classCode="OBS" moodCode="EVN">
<realmCode code="QD" />
<performer typeCode="PRF">
<locatedEntity classCode="LOCE">
<locatedOrganization classCode="ORG" determinerCode="INSTANCE">
</locatedOrganization>
<subjectOf typeCode="SBJ">
<annotation classCode="ACT" moodCode="EVN">
<text><![CDATA[Quest Diagnostics Nichols Institute <br /> 33608 Ortega Highway <br /> San Juan Capistrano, CA 92690-6130]]></text> <!-- Performing lab address information would be passed here -->
<statusCode code="Update"/><!-- This is the update flag for the performing lab address field-->
</annotation>
</subjectOf>
</locatedEntity>
</performer>
<pertinentInformation2 typeCode="PERT">
<observationEvent classCode="OBS" moodCode="EVN">
<referenceRange nullFlavor="" typeCode="REFV">
<interpretationRange classCode="OBS" moodCode="EVN">
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="REFERENCERANGE"> <!-- Reference Range Information -->
</code>
<text><![CDATA[IgA SUBCLASSES __IgA1 (UOM mg/dL) 6-11 months: 1-115 mg/dL 1 year: 3-120 mg/dL 2 years: 7-132 mg/dL 3 years: 11-143 mg/dL 4-7 years: 23-175 mg/dL 8-11 years: 33-204 mg/dL 12-17 years: 47-249 mg/dL >=18 years: 46-378 mg/dL IgA SUBCLASSES __IgA2 (UOM mg/dL) 6-11 months: 0-19 mg/dL 1 year: 0-23 mg/dL 2 years: 1-23 mg/dL 3 years: 1-25 mg/dL 4-7 years: 2-33 mg/dL 8-11 years: 2-37 mg/dL 12-17 years: 4-50 mg/dL >=18 years: 13-91 mg/dL IgA SUBCLASSES __IgA, Serum (UOM mg/dL) 6-11 months: 3-101 mg/dL 1 year: 6-112 mg/dL 2 years: 11-134 mg/dL 3 years: 16-155 mg/dL 4-7 years: 31-214 mg/dL 8-11 years: 43-268 mg/dL 12-17 years: 65-356 mg/dL >=18 years: 81-463 mg/dL]]></text>
<statusCode code="token"/>
</annotation>
</subjectOf>
</interpretationRange>
</referenceRange>
</observationEvent>
</pertinentInformation2>
<pertinentInformation3 typeCode="PERT">
<scheduleEvent classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="SETUPSCHEDULE"/>
<text><![CDATA[Set up: 6 days a week a.m.; Report available: 2-3 days]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</scheduleEvent>
</pertinentInformation3>
<pertinentInformation3 typeCode="PERT">
<scheduleEvent classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="SETUPTIME"/>
<text><![CDATA[Set up: 6 days a week a.m.; Report available: 2-3 days]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</scheduleEvent>
</pertinentInformation3>
<pertinentInformation3 typeCode="PERT">
<scheduleEvent classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="SETUPDAYS"/>
<text><![CDATA[Sets up 6 days a week.]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</scheduleEvent>
</pertinentInformation3>
<pertinentInformation3 typeCode="PERT">
<scheduleEvent classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="REPORTAVAILABLE"/>
<text><![CDATA[2-3 days]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</scheduleEvent>
</pertinentInformation3>
<pertinentInformation6 typeCode="PERT">
<specimenHandling classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="PREFERREDSPECIMEN"/>
<text><![CDATA[2 mL Second void urine <strong>or </strong>2-hour urine <strong>or </strong> 2 mL Urine with no preservative]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</specimenHandling>
</pertinentInformation6>
<pertinentInformation6 typeCode="PERT">
<specimenHandling classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="MINIMUMVOLUME"></code>
<text><![CDATA[1 mL]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</specimenHandling>
</pertinentInformation6>
<pertinentInformation6 typeCode="PERT">
<specimenHandling classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="OTHERACCEPTABLESPECIMEN"></code>
<text><![CDATA[2 mL Second void urine <strong>or </strong>2-hour urine <strong>or </strong> 2 mL Urine with no preservative]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</specimenHandling>
</pertinentInformation6>
<pertinentInformation6 typeCode="PERT">
<specimenHandling classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="INSTRUCTIONS"></code>
<text><![CDATA[<strong>Whole Blood: </strong>Normal phlebotomy procedure. Store and ship <br /> room temperature immediately. Do not freeze. <br /> <strong><br /> Saliva:</strong> Collect saliva using Oragnene self collection kit. Store and ship room temperatur immediately. Do not freeze.]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</specimenHandling>
</pertinentInformation6>
<pertinentInformation6 typeCode="PERT">
<specimenHandling classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="TRANSPORTCONTAINER"></code>
<text><![CDATA[APTIMA<sup>®</sup> transport tube]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</specimenHandling>
</pertinentInformation6>
<pertinentInformation6 typeCode="PERT">
<specimenHandling classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="TRANSPORTTEMPERATURE"></code>
<text><![CDATA[<p>Refrigerated (cold packs)</p>]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</specimenHandling>
</pertinentInformation6>
<pertinentInformation6 typeCode="PERT">
<specimenHandling classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="SPECIMENSTABILITY"></code>
<text><![CDATA[Room temperature: 48 hours<br /> Refrigerated: 7 days<br /> Frozen: 30 days]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</specimenHandling>
</pertinentInformation6>
<pertinentInformation6 typeCode="PERT">
<specimenHandling classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="REJECTCRITERIA"></code>
<text><![CDATA[Specimens containing heparin; Leaking samples; Uncapped samples; Broken container; Non Aptima; Vaginal Swab Collection Kit]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</specimenHandling>
</pertinentInformation6>
<pertinentInformation6 typeCode="PERT">
<specimenHandling classCode="ACT" moodCode="EVN" >
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="PATIENTPREPARATION"></code>
<text><![CDATA[<br/><b> Patient preparation:</b></br> Collect peak at end of 60 minutes IV infusion, 30 minutes after end of IV infusion, or 30-60 minutes after IM dose]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</specimenHandling>
</pertinentInformation6>
<pertinentInformation7 typeCode="PERT">
<medicalInformation classCode="ACT" moodCode="EVN">
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="METHODOLOGY"/>
<text><![CDATA[Real-Time Polymerase Chain Reaction (RT-PCR)]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</medicalInformation>
</pertinentInformation7>
<pertinentInformation7 typeCode="PERT">
<medicalInformation classCode="ACT" moodCode="EVN">
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="CLINICALSIGNIFICANCE"/>
<text><![CDATA[Maternal Cell Contamination Study, STR Analysis, provides assurance that test results from fetal specimens are not influenced by contaminating maternal material. This test also allows for establishing the proper maternal-fetal relationship between specimens by using sophisticated analysis of 15 highly polymorphic STR loci.]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</medicalInformation>
</pertinentInformation7>
<pertinentInformation7 typeCode="PERT">
<medicalInformation classCode="ACT" moodCode="EVN">
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="LIMITATION"/>
<text><![CDATA[Variations in two genes (VKORC1 and CYP2C9) are particularly important in warfarin metabolism. VKORC1 may explain 30% of the variability in drug response between patients and changes in CYP2C9 may explain 10% of the dose variation. While significant portion of the dose variability can be accounted for by genetic factors, this testing will not determine all factors associated with dose variability.]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</medicalInformation>
</pertinentInformation7>
<pertinentInformation7 typeCode="PERT">
<medicalInformation classCode="ACT" moodCode="EVN">
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="ASSAYVIEW"/>
<text><![CDATA[Sample Value]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</medicalInformation>
</pertinentInformation7>
<pertinentInformation7 typeCode="PERT">
<medicalInformation classCode="ACT" moodCode="EVN">
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN">
<code code="INDICATIONS"/>
<text><![CDATA[Sample Value]]></text>
<statusCode code="Updated"/>
</annotation>
</subjectOf>
</medicalInformation>
</pertinentInformation7>
</order>
</subjectOf>
<coveredPartyOf typeCode="COV">
<financialTransactionEvent classCode="XACT" moodCode="EVN">
<id extension="12343" assigningAuthorityName="BILLCODE"/>
<subjectOf typeCode="SUBJ">
<annotation classCode="ACT" moodCode="EVN" >
<realmCode code="QD" />
<code code="CPTCODE"></code>
<text><![CDATA[Sample Value]]></text><!-- CPT Code information would be passed here -->
<statusCode code="Updated"/><!-- Updated Flag for this field-->
</annotation>
</subjectOf>
</financialTransactionEvent>
</coveredPartyOf>
</testCodeIdentifier>
</subject>
<custodian contextControlCode="AP" typeCode="CST">
<assignedDevice classCode="ASSIGNED">
<realmCode code="QD" />
<id extension="QTIM"/>
<assignedRepository classCode="DEV" determinerCode="INSTANCE">
<name/>
</assignedRepository>
</assignedDevice>
</custodian>
</registrationEvent>
</subject>
</controlActEvent>
</QDTM_IN300301QD>
我有上面的XML需要使用XPath来解析;我正在使用顶部的代码来解析使用。我想我做错了什么,因为当通过代码标签代码属性=“CPTCODE”访问时,它没有获取文本标签的数据
提前致谢...
最佳答案
这是 XPath 中最常见的常见问题(搜索 XPath 和默认命名空间)。
简而言之,Xpath 始终将无前缀的名称视为属于“无命名空间”。
如果 XML 文档没有默认 namespace ,则任何名称不带前缀的元素确实属于“无 namespace ”,并且表达式:
/name1/name2
选择名为 name2
的任何元素,该元素是名为 name1
的顶部元素的子元素。
如果 XML 文档具有全局定义的默认命名空间,则相同的表达式:
/name1/name2
什么也不选择,因为“无命名空间”中没有元素(所有元素都在默认的非空命名空间中),因此尝试选择名称为 name1
, 的元素name2
或 whatevername
结果选择 0 个元素。
解决方案:
使用您的 XPath 引擎 API 来“注册命名空间”以及与其关联的前缀,例如 “x”
。然后将表达式重写为:
/x:name1/x:name2
最后一个表达式正确选择了所需的节点。
关于java - XPATH + 在 java 中解析 XML + 需要检查属性以访问下一个同级值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8578112/
我正在尝试使此 OSX 代码(golfed 以便于讨论)在 Ubuntu Linux 上运行。 cat >main.c #include #include void provided_by_ma
带有 .next() jquery 方法的小选择器让我发疯。 故事是这样的,我在表行上使用 Bootstrap 过滤器和 jquery。当过滤器执行时,它会将显示样式属性更改为 table-row,如
无法理解为什么此代码将 DIV 元素的颜色更改为蓝色,但不更改 SPAN 元素的颜色。有什么想法吗? $(document).ready(function(){ $
这个问题在这里已经有了答案: How can I target a specific group of siblings in a flat hierarchy? (1 个回答) 关闭 6 年前。
请看here ,左侧的菜单应该在复选框选中的属性上滑入和滑出,但我的 CSS 不工作,任何人都可以帮助我。在我的代码菜单中,当前设置为 left:-240px,因为它应该滑入 left:0 选中复选框
我正在创建的这个系统遇到了问题。我总共有四个兄弟 div 容器。它们在普通桌面 View 中是这样的: 蓝红蓝红 这适用于 2/3 视口(viewport)以将 background-color 显示
使用 UITabBar,我有 4 个同级 View (每个选项卡项目一个)。加载应用程序时,第一个选项卡项目和 View 可见。第一个 View 有一个发布 NSNotification 的 IBAc
这个问题已经有答案了: Self-references in object literals / initializers (31 个回答) 已关闭 9 年前。 我有一个json结构如下:
我有多个带有标题、描述和号召性用语的产品。每个的字数没有规定。我正在使用 flexbox 来展示这些产品,这样每个元素的容器高度相等,并且可以轻松地清除到下一行,而不必弄乱第 nth-child。 我
我正在努力解决 IE7 问题。我希望我的兄弟 div 与其 sibling 的宽度相同。第一个 sibling 充当标题,而其他 sibling 有一定的尺寸。我可以使用一些建议。 http://js
我正在创建 3 行,每行有 4 列。但我想要实现的是,当 1 调整一行中任何列的大小时,其余列应根据行的总剩余宽度调整大小。假设如果行的总宽度为 100%,并且如果我将第一列的大小调整 60%,则剩余
到目前为止,我有以下cinoptions: cino= cino+=:0 cino+=g0 cino+=p0 cino+=(0 cino+={0 cino+=l1 cino+=t0 cino+=u2
如果我没有解释清楚,请提前道歉。我会尽力澄清我正在尝试做的事情。事不宜迟...假设您在页面上有一系列数字(仅由一个空格分隔),其中括号表示您所在的当前页面。 在页面上看起来是这样的: [1] 2 3
我的 parent 中有两个 sibling ,并且 sibling 的数据正在更新,数据已更新,但是 ngOnInit(){} 未调用。 https://stackblitz.com/edit/an
我正在创建一个可滑动的菜单,它可以正常工作,但有一个方面除外。我希望菜单始终具有 100% 的高度……无论用户在页面上向下滚动多远。但是,每当我将其设置为 height: 100%; 时,菜单都不会滑
first-child last-child first-child-1 last-chi
我想显示一个评论列表以及每个评论的评论列表等等: 这是我的 HTML 代码: Titre d'un commentaire statique Qui cum ven
我进行了彻底的搜索,但没有找到任何关于如何查询和检索多个 XML 同级的值的示例或指导。 有很多关于如何检索单个兄弟值的示例。 例如,给出以下 XML 片段: 800000 80000
这个问题已经有答案了: Is there a "previous sibling" selector? (33 个回答) 已关闭 7 年前。 在 CSS 中,如果同级元素位于输出中的上方(HTML 中
console.log((this).sibling('.advanceOptWrap')); 以上代码返回 Uncaught TypeError: $(...).sibling is not a f
我是一名优秀的程序员,十分优秀!