Xpath code to fetch value from specific line - xpath

I am trying to fetch a value from an XML. The XML contains many rows. However, I need to fetch the value from a specific row which changes in position from one XML to another.
I need to fetch value from the row that contains <FL val="Job Opening Status">. In this case the value is "Search".
<JobOpenings>
<row no="1">
<FL val="JOBOPENINGID">384474000005082052</FL>
<FL val="Job Opening ID">
<![CDATA[J9298]]>
</FL>
<FL val="SMOWNERID">384474000003450003</FL>
<FL val="Account Manager">
<![CDATA[xsxsxs]]>
</FL>
<FL val="Job Type">
<![CDATA[Permanent]]>
</FL>
<FL val="Is Hot Job Opening">
<![CDATA[false]]>
</FL>
<FL val="Publish">
<![CDATA[false]]>
</FL>
<FL val="No of Candidates Associated">
<![CDATA[2]]>
</FL>
<FL val="Posting Title">
<![CDATA[Projekteinkäufer]]>
</FL>
<FL val="Last Activity Time">
<![CDATA[2019-06-18 10:15:14]]>
</FL>
<FL val="Job Opening Status">
<![CDATA[Search]]>
</FL>
<FL val="Date Opened">
<![CDATA[2019-06-18]]>
</FL>
<FL val="CLIENTID">384474000000417148</FL>
<FL val="Client Name">
<![CDATA[xsxsxxxxssss]]>
</FL>
<FL val="CONTACTID">384474000005082043</FL>
<FL val="Contact Name">
<![CDATA[xsxsxxxxxssssssxxxxx]]>
</FL>
<FL val="RECRUITERID">384474000003450003</FL>
<FL val="Assigned Recruiter">
<![CDATA[xsxsxsxsxssx]]>

To get the xpath for search element.Try below xpath.
//JobOpenings//row//FL[#val='Job Opening Status']
DEMO:
//JobOpenings//row//FL[#val='Job Opening Status'][contains(.,'Search')]
DEMO 2:

Related

How to remove repeated HTML elements except first one?

I have an HTML file with some repeated text along the document. The repeated strings have font size 4 or 5 and my goal is to delete all those
repeated strings except the first appeareance.
For example:
India! with size=5 appears 9 times and with size=4 appears 2 times. Then I'd like to remove all appeareances of India with size=5 and leave the first.
India!
I've tried with sed command in bash (I'm open to suggestions to do it with other tools) doing as below, but doesn't work because removes everything after the first match:
sed 's/<font size=\"[4-5]\".*<\/font>//g'
and I get as output only this:
<!DOCTYPE html> <html> <body>
<h1>Some header</h1>
<p> </p>
<p> This is other text. </p>
</body>
</html>
My input file is this:
<!DOCTYPE html>
<html>
<body>
<h1>Some header</h1>
<p>
<font size="5">India!</font>
<p>
<font size="4">Japan!</font>
</p>
</p>
<p>Some text 1</p>
<p>
<font size="5">India!</font>
</p>
<p>Some text 2</p>
<p>
<font size="5">India!</font>
<p>
<font size="4">Japan!</font>
</p>
</p>
<p>Some text 3</p>
<p>
<font size="5">Uganda!</font>
</p>
<p>Some text 4</p>
<p>
<font size="5">India!</font>
<p>
<font size="4">Japan!</font>
</p>
</p>
<p>Some text 5</p>
<p>
<font size="5">India!</font>
</p>
<p>Some text 6</p>
<p>
<font size="5">Cameroon!</font>
</p>
<p>Some text 7</p>
<p>
<font size="4">India!</font>
</p>
<p>Some text 8</p>
<p>
<font size="5">India!</font>
</p>
<p>Some text 9</p>
<p>
<font size="5">India!</font>
</p>
<p>Some text 10</p>
<p>
<font size="5">Pakistan!</font>
</p>
<p>Some text 11</p>
<p>
<font size="5">Pakistan!</font>
</p>
<p>Some text 12</p>
<p>
<font size="5">India!</font>
</p>
<p>Some text 13</p>
<p>
<font size="4">Uganda!</font>
</p>
<p>
<font size="5">India!</font>
</p>
<p>Some text 14</p>
<p>
<font size="4">India!</font>
</p>
<p> This is other text. </p>
</body>
</html>
I show in image below the input(to the left) and output desired(to the rigth) in text format and HTML preview.
As you requested in your comment, here is a slightly different program to remove the associated paragraph tags as well.
In order to remove the <p> and </p> before and after the lines you want removed ( the duplicates ), I found it conceptually easier to run through the file twice.
The first pass through the file, I keep track of whether or not I've seen the combination of font size and country just as before. In addition, I also track the line numbers (FNR) of the lines that need to be removed. The code "knows" the first pass through the file when NR == FNR. NR is total number of records so far and FNR is the record number in the file. Thus, when they are equal, awk is parsing the first file.
In the second pass through the same input file, I print out the current record if it is not marked as suppressed. The FNR is used to index the suppressed array because FNR is the same in the first pass as the second pass of the file.
Lastly, in order to tell awk to parse the file twice, we'll need to pass the input file to awk twice on the command line.
Here's the revised code. I also illustrate how to parse your input file twice by adding the file (let's call it input.html) two times to the command line:
awk -F"[\"<>= ]*" '
NR == FNR {
if ( $2 == "font" )
{
if (seen[ $4,$5 ] )
suppress[ NR - 1 ] = suppress[ NR ] = suppress[ NR + 1 ] = 1
seen[$4,$5] = 1
}
next
}
! suppress[ FNR ]
' input.html input.html
Here's an awk 'solution' for you:
awk -F"[\"<>= ]*" '
$2 == "font" {
if (!printed[ $4,$5 ] )
print
printed[$4,$5] = 1
next
}
1
'
Since awk is not a robust HTML parser, it's really not a great general solution. However, if your input files are consistent, this small script may do the trick.

Is it possible to identify multiple values in a WHENNOT rule when defining WIT object?

We are attempting to expose a new field to only two groups (of many) within a TFS team project. We would like to implement a rule to the WIT object for which multiple values would satisfy the issue.
We have tried nested..
<WHENNOT field="System.AreaId" value="1"/>
<WHENNOT field="System.AreaId" value="2"/>
repeated...
<WHENNOT field="System.AreaId" value="1">
</WHENNOT>
<WHENNOT field="System.AreaId" value="2">
</WHENNOT>
and some guesses to the syntax..
<WHENNOT field="System.AreaId" value="1 or 2"/>
<WHENNOT field="System.AreaId" value="1 || 2"/>
<WHENNOT field="System.AreaId" value="1, 2"/>
without achieving the intended result.
<FIELD name="Original Estimate" refname="Microsoft.VSTS.Scheduling.OriginalEstimate" type="Double" reportable="measure" formula="sum">
<HELPTEXT>Initial value for Remaining Work - set once, when work begins</HELPTEXT>
<WHENNOT field="System.AreaId" value="24">
<READONLY />
</WHENNOT>
<WHENNOT field="System.State" value="To Do">
<READONLY />
</WHENNOT>
<WHEN field="System.State" value="Done">
<REQUIRED />
</WHEN>
</FIELD>
We would like to show the field based on whether the WIT is associated with Area ID 1 or 2, but otherwise hide from all of others.
You can't combine 2 WHENNOT because they cancel each other.
You need to use <WHEN field="System.AreaId" value="{id}"> <READONLY> </WHEN>
with all the areas (unless 1 and 2).

oracle query to get list of xml nodes and their values using oracle

I have a XML column and i need help to write the query to display the nodes and their values.
below is the data from my xml column:
<item_content>
<stimulus_reference>
<table_wrapper>
<table frame="all" colsep="1" rowsep="1" pgwide="0">
<tgroup cols="3">
<thead>
<row>
<entry />
<entry align="center">Male</entry>
<entry align="center">Female</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left">Juniors</entry>
<entry align="right">12</entry>
<entry align="right">3</entry>
</row>
<row>
<entry align="left">Seniors</entry>
<entry align="right">9</entry>
<entry align="right">21</entry>
</row>
</tbody>
</tgroup>
</table>
</table_wrapper>
<rationale>This is a rationale paragraph</rationale>
</stimulus_reference>
<task>
<item_stem>
<stem_paragraph>The table above shows the distribution of students that attended a concert, by class and gender.</stem_paragraph>
</item_stem>
<item_response>
<response_choices>
<columnar_choice_list>
<columns align="character" align_character="1">
<choice_row numeric_identifier="1">
CHROW1
<choice_cell>3</choice_cell>
</choice_row>
<choice_row numeric_identifier="2">
CHROW2
<choice_cell>15</choice_cell>
</choice_row>
<choice_row numeric_identifier="3">
CHROW3
<choice_cell>2102</choice_cell>
</choice_row>
<choice_row numeric_identifier="4">
CHROW4
<choice_cell>321</choice_cell>
</choice_row>
ColumnsData
</columns>
</columnar_choice_list>
</response_choices>
</item_response>
</task>
<math_expression>1+2=3</math_expression>
</item_content>
i want the output in the below format
Node_Name Node_val
stimulus_reference
table_wrapper
table
tgroup
thead
row
entry
entry Male
entry Female
tbody
row
entry Juniors
entry 12
entry 3
row
entry Seniors
entry 9
entry 21
task
item_stem
stem_paragraph The table above shows the distribution of students that attended a concert, by class and gender.
item_response
response_choices
columnar_choice_list
columns ColumnsData
choice_row CHROW1
choice_cell 3
choice_row CHROW2
choice_cell 15
choice_row CHROW3
choice_cell 2102
choice_row CHROW4
choice_cell 321
appreciate your help on this.
//* returns all nodes on all levels.
name() returns node name
text() returns node value
If you want only text nodes you have to replace //* with //*[text()]
select * from xmltable('//*' passing xmltype ('
<item_content>
<stimulus_reference>
<table_wrapper>
<table frame="all" colsep="1" rowsep="1" pgwide="0">
<tgroup cols="3">
<thead>
<row>
<entry />
<entry align="center">Male</entry>
<entry align="center">Female</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left">Juniors</entry>
<entry align="right">12</entry>
<entry align="right">3</entry>
</row>
<row>
<entry align="left">Seniors</entry>
<entry align="right">9</entry>
<entry align="right">21</entry>
</row>
</tbody>
</tgroup>
</table>
</table_wrapper>
<rationale>This is a rationale paragraph</rationale>
</stimulus_reference>
<task>
<item_stem>
<stem_paragraph>The table above shows the distribution of students that attended a concert, by class and gender.</stem_paragraph>
</item_stem>
<item_response>
<response_choices>
<columnar_choice_list>
<columns align="character" align_character="1">
<choice_row numeric_identifier="1">
CHROW1
<choice_cell>3</choice_cell>
</choice_row>
<choice_row numeric_identifier="2">
CHROW2
<choice_cell>15</choice_cell>
</choice_row>
<choice_row numeric_identifier="3">
CHROW3
<choice_cell>2102</choice_cell>
</choice_row>
<choice_row numeric_identifier="4">
CHROW4
<choice_cell>321</choice_cell>
</choice_row>
ColumnsData
</columns>
</columnar_choice_list>
</response_choices>
</item_response>
</task>
<math_expression>1+2=3</math_expression>
</item_content>')
columns
node_name varchar2(100) path 'name()',
node_value varchar2(100) path 'text()'
)

Exchange Server changing daily recurrence pattern to weekly?

I have registered an appointment in Outlook 2003 SP3 with recurrence pattern Daily, every workday, no end date.
The data are stored in MS Exchange Server 2010.
If I query Exchange Web Services for that event (some detail info) it returns a weekly occurrence for every Monday..Friday:
<Recurrence>
<WeeklyRecurrence>
<Interval>1</Interval>
<DaysOfWeek>Monday Tuesday Wednesday Thursday Friday</DaysOfWeek>
</WeeklyRecurrence>
<NoEndRecurrence>
<StartDate>2012-12-03+01:00</StartDate>
</NoEndRecurrence>
</Recurrence>
Technically, these are the same days, but I'm storing this in another system and would like an Outlook daily appointment to show up there as a daily appointment too ;-)
Is this a known issue?
Can anything be done to prevent this?
[I can't myself convert "Weekly Mon-Fri" back to "Daily every workday" because that would modify a 'real' "Weekly Mon-Fri" appointment]
Thanks
Jan
Full request:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
<soapenv:Header>
<typ:RequestServerVersion Version="Exchange2007_SP1"/>
<typ:MailboxCulture>en-US</typ:MailboxCulture>
</soapenv:Header>
<soapenv:Body>
<mes:GetItem>
<mes:ItemShape>
<typ:BaseShape>IdOnly</typ:BaseShape>
<typ:BodyType>Text</typ:BodyType>
<typ:AdditionalProperties>
<typ:FieldURI FieldURI="item:Subject" />
<typ:FieldURI FieldURI="item:ReminderIsSet" />
<typ:FieldURI FieldURI="item:ReminderMinutesBeforeStart" />
<typ:FieldURI FieldURI="calendar:Location" />
<typ:FieldURI FieldURI="calendar:IsAllDayEvent" />
<typ:FieldURI FieldURI="calendar:LegacyFreeBusyStatus" />
<typ:FieldURI FieldURI="calendar:Recurrence" />
<typ:FieldURI FieldURI="item:Body"/>
</typ:AdditionalProperties>
</mes:ItemShape>
<mes:ItemIds>
<typ:ItemId Id="AQMkAD[snip]2HQAAAA=="/>
</mes:ItemIds>
</mes:GetItem>
</soapenv:Body>
</soapenv:Envelope>
Full response:
<Envelope>
<Header>
<ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="722" MinorBuildNumber="0" Version="Exchange2010"/>
</Header>
<Body>
<GetItemResponse>
<ResponseMessages>
<GetItemResponseMessage ResponseClass="Success">
<ResponseCode>NoError</ResponseCode>
<Items>
<CalendarItem>
<ItemId Id="AQMkAD[snip]2HQAAAA==" ChangeKey="DwAAA[snip]ns8Yn"/>
<Subject>Elke werkdag, geen einddatum</Subject>
<Body BodyType="Text"/>
<ReminderIsSet>false</ReminderIsSet>
<ReminderMinutesBeforeStart>15</ReminderMinutesBeforeStart>
<IsAllDayEvent>false</IsAllDayEvent>
<LegacyFreeBusyStatus>Busy</LegacyFreeBusyStatus>
<Location/>
<Recurrence>
<WeeklyRecurrence>
<Interval>1</Interval>
<DaysOfWeek>Monday Tuesday Wednesday Thursday Friday</DaysOfWeek>
</WeeklyRecurrence>
<NoEndRecurrence>
<StartDate>2012-12-03+01:00</StartDate>
</NoEndRecurrence>
</Recurrence>
</CalendarItem>
</Items>
</GetItemResponseMessage>
</ResponseMessages>
</GetItemResponse>
</Body>
</Envelope>
After another hour of digging I found "Daily and Weekly recurrence pattern trouble" on a Microsoft forum stating that it is not possible:
"The only way to define a recurrence pattern for "Every weekday" in EWS is to use WeeklyRecurrencePatternType. DailyPatternType can only be used to define a recurrence where each occurrence happens N day after the previous one.
In other words, there is no way to distinguish the two in EWS."

Magento - Move the "terms and conditions" from the last checkout step to the first one

How can I move the terms and conditions from the last checkout step to the first one ?
I have tried only with the xml files, but I can't continue to the next step in this case.
Please help to do that.
In checkout.xml, move
<block type="checkout/agreements" name="checkout.onepage.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
from <checkout_onepage_review> handle into <checkout_onepage_index>:
You have to modify
<block type="checkout/onepage_billing" name="checkout.onepage.billing" as="billing" template="checkout/onepage/billing.phtml"/>
into
<block type="checkout/onepage_billing" name="checkout.onepage.billing" as="billing" template="checkout/onepage/billing.phtml"></block>
and put the line inside.
In info.phtml (or review.phtml for v1.4.2) cut
<?php echo $this->getChildHtml('agreements') ?>
and paste that line you've just cut into billing.phtml.
Long time done this post but those that are still in need:
To add to that contributed from #OSdave - as #Bizboss is saying the terms and conditions checkbox doesn't have to be checked to proceed to the next step. To provide a front end solution with least fuss just add required-entry to the class name - e.g.
<input type="checkbox" id="agreement-<?php echo $_a->getId()?>" name="agreement[<?php echo $_a->getId()?>]" value="1" title="<?php echo $this->htmlEscape($_a->getCheckboxText()) ?>" class="checkbox required-entry" />
This employs JS validation to prevent it from proceeding to the next stage without being checked.

Resources