I have the below xml and I want to be able to get to the tel value where the type value = 1.
I have attempted quite a few different scenarios and got to the following;
//Telephone/type[text()='1']/parent::tel but this is not working. Please can someone help.
<Telephone>
<Number>
<tel>01242123456</tel>
<CountryCode>GB</CountryCode>
<CountryDiallingCode>+44</CountryDiallingCode>
</Number>
<type>1</type>
</Telephone>
<Telephone>
<Number>
<tel>07777777777</tel>
<CountryCode>GB</CountryCode>
<CountryDiallingCode>+44</CountryDiallingCode>
</Number>
<type>3</type>
</Telephone>
Just try
//Telephone[type = '1']/Number/tel
Related
I got problem such as :
id="tabscontent:tabView:BWconent_0:j_idt670"
After exceute
id changed = "tabscontent:tabView:BWconent_0:j_idt682"
670 change 682
Everyone know how to make : contains() or starts-with() or ends-with()
Please to help me
Thank you so much
P/s : I mean using xpath id for Katalon Testcase
Assuming that the beginning part of the id is static you can use starts-with() like this:
//*[starts-with(#id, 'tabscontent:tabView:BWconent_0:treeLeft_0:1:j_idt')]
The above XPath will return elements with id attribute value starts with "tabscontent:tabView:BWconent_0:treeLeft_0:1:j_idt"
Use this
TestObject myObject = new TestObject().addProperty('css', ConditionType.EQUALS, 'a[id^="tabscontent:tabView:BWconent_0"]')
The ^="some text" denotes "starts-with" for css selectors.
You will need to import TestObject and ConditionType classes. You can just press Ctrl+Shift+O in script mode and Katalon will do the rest.
I'm trying to run a meta-regression with MD's as dependent variable. I want to add a numeric moderator (year published) to the rma.uni function.
Formula so far:
metafor::rma.uni(yi=MCID12, sei=SE12, method="FE", data=Pain, slab=paste(Pain$Author, Pain$Year), weighted=TRUE, subset=(Pain$outcomegruppe=="9"), mods =("Pain$Year") )
I always get the error message:
Error in metafor::rma.uni(yi = MCID12, sei = SE12, method = "FE", data = Pain, :
Model matrix contains character variables.
My "Year" veriable is definetly numeric. As soon as I don't use the "mods" argument, everything works normal.
Could anyone help me with this problem?
Thanks in advance!
Don't put Year in quotes. Also, you don't need the Pain$ parts and weighted=TRUE is the default. This should do it:
metafor::rma.uni(yi=MCID12, sei=SE12, method="FE", data=Pain, slab=paste(Author, Year),
subset=(outcomegruppe=="9"), mods=~Year)
I have this xml that contains certificates and its attributes. Here is the xml over which I am running the extraction query
<Certificates>
<CertificateAndChain>
<Certificate>
<FriendlyName />
<Thumbprint>EE8B375347FCADDC25547FDDF61866E07D5B6A71</Thumbprint>
<SerialNumber>256BB11DB5BE889E46EBCD85608DA849</SerialNumber>
<Version>3</Version>
<SignatureAlgorithm>sha1RSA</SignatureAlgorithm>
<Issuer>CN=certname</Issuer>
<Subject>CN=certname</Subject>
<NotAfter>2040-09-26T18:30:00Z</NotAfter>
<NotBefore>2016-09-27T18:30:00Z</NotBefore>
<IsVerified>false</IsVerified>
</Certificate>
.
.
.(continued)...
I have written another test over this xml that needs to extract thumbprints of all the certificates that are about to get expired in next 10 days.
As part of the test, , I have written the Extraction query as:
<XPath2ResponseParameter Name="TPName"><ExtractionQuery><![CDATA[string(//CertificateAndChain/Certificate[NotAfter[text() <= (current-dateTime() + xs:dayTimeDuration('P10D'))]]/Thumbprint)]]></ExtractionQuery></XPath2ResponseParameter>
The test is in xml file as well. However, when I run the test, I get this exception:
A sequence of more than one item is not allowed as the first argument of string().
This is probably happening because there are multiple certificate elements present in the xml. So, I couldn't figure out the way to extract all the thumbprints failing the mentioned condition(there could be more than 1 and I need to extract all of them)
Can anyone help me fix this?
You can invoke function in axis when using XPath 2.0. So, try to move string() function to the end of the inner XPath (formatted for readability) :
//CertificateAndChain
/Certificate[
NotAfter[
text() <= (current-dateTime() + xs:dayTimeDuration('P10D'))
]
]/Thumbprint
/string()
UPDATE :
Since CDATA can't receive multiple strings in this context, according to the error message in your first comment, then you need to combine those strings into one, presumably using string-join() :
string-join(
//CertificateAndChain
/Certificate[
NotAfter[
text() <= (current-dateTime() + xs:dayTimeDuration('P10D'))
]
]/Thumbprint
/string()
,' ')
I have a code such as:
<out:a>
<out:Name Type="First" TypeCode="Best">JAE</out:Name>
</out:a>
When I gave the xpath expression as
//*[name()='out:Name'],
I got the result as
<out:Name Type="First" TypeCode="Best" xmlns:out3="abc" xmlns:out2="def" xmlns:out1="ghi" xmlns:out="jkl">JAE</out:Name>
I would like to get the value JAE using xpath expression. Could someone help me in that please?
Add text() on the end:
//*[name()='out:Name']/text()
Or
//out:Name/text()
It depends on the tool you use.
With java / Xpath and evaluate, your xpath expression works well:
expression=" //*[name()='out:Name']";
String value = xPath.evaluate(expression, document);
System.out.println("EVALUATE:"+value); // => EVALUATE:JAE
I am using the following format for my xpath expression in VB.Net workflow:
String(xpath)
which returns me the expected string value, but also a new line charac after the value which is breaking my logic.
How do I get rid of that new line?
Any pointers?
More Info as requested:
The normalize-space is still returning the new line.
The xml is too big, so pasting the snippet under its immediate parent here:
<Characteristic_Value_Population_Rule_SpecChar_Value_Population_Rule ID="f0baf095-5e84-4146-9c72-7691205df16b" xsi:type="SpecChar_Value_Population_Rule" Pattern="T_RelatedEntityRule">
<Entity_T_RelatedEntityGroup_AND ID="a9adc94f-615b-477b-8841-94887429a83e" xsi:type="T_RelatedEntityGroup_AND" Pattern="TRelated_EntityGroup">
<Entities_TRule_Value_EntityRef ID="f521569f-41a3-42ad-9974-3aea9557460b" xsi:type="TRule_Value_EntityRef" Pattern="TRule_Complex_Value">
<Name>Modem ADSL/VDSL/TV/PSTN b-box 3 0</Name>
<Entity>000006,000069,000078</Entity>
</Entities_TRule_Value_EntityRef>
<Entities_TRule_Value_EntityRef ID="9025dfc0-bd7d-4252-8dad-f95a818b8688" xsi:type="TRule_Value_EntityRef" Pattern="TRule_Complex_Value">
<Name>Modem ADSL/VDSL2/TV/Italk/off b-box 2 039</Name>
<Entity>000006,000069,000077</Entity>
</Entities_TRule_Value_EntityRef>
<Name>Acquisition Type is Rent in the context of Belgacom Internet</Name>
</Entity_T_RelatedEntityGroup_AND>
<Name>Acquisition Type is Rent in the context of Belgacom Internet</Name>
<Characteristic ID="ae3f9304-31a7-4c0b-8723-c553b136410e" Pattern="TSpecChar" OrigType="SpecCharItem">
<Specification_Characteristic ID="c5dec18e-806c-46d1-8294-e83117650b5b" Pattern="TSpecCharValue" OrigType="SpecCharValueItem">
<Value>Rent</Value>
<IsUserDefinedValue>false</IsUserDefinedValue>
</Specification_Characteristic>
<Name>Acquisition Type</Name>
</Characteristic>
</Characteristic_Value_Population_Rule_SpecChar_Value_Population_Rule>
</Package>
I am trying to get the value c5dec18e-806c-46d1-8294-e83117650b5b which the xpath expression does return but with the new line.
i am now using the xpath:
string(normalize-space(//Package/Characteristic_Value_Population_Rule_SpecChar_Value_Population_Rule/Characteristic/Specification_Characteristic/#ID))
Try String(normalize-space(xpath)). If that does not help then show us more context.