Removing parent nodes from xml file in r - r

I have xml output below. I am trying to remove parents using XML or xml2 library from R. I found a similar post here but those functions somehow gave me an error. I am trying to remove those parents until analysisdata parent. That is what I am going to parse.
<assessment>
<itembank />
<instrument id="797393 ">
<form id="Math G3">
<formitem id="8243" position="0" />
</form>
</instrument>
<admin id="797393 " instrument="797393 ">
<genatt name="adminperiod" value="SP19" />
<responseanalyses>
<responsebankref id="3M" />
<analysisdefs>
<analysisoption name="mark" value="no" />
<analysisoption name="notreached" value="ASNOTPRESENTED" />
<statentity type="item" id="8243" varname="I_8243">
<genatt name="type" value="CR" />
<genatt name="codestart" value="0" />
<genatt name="validcodes" value="2" />
<genatt name="omitcode" value="9" />
<genatt name="notpresentedcode" value="8" />
<statentity code="0.000000" id="0.000000" type="itemscorept" />
<statentity code="1.000000" id="1.000000" type="itemscorept" />
<statentity code="9" id="omit" type="itemscorept" />
</statentity>
<genatt name="type" value="CR" />
<genatt name="codestart" value="0" />
<genatt name="validcodes" value="2" />
<genatt name="omitcode" value="9" />
<genatt name="notpresentedcode" value="8" />
<statentity code="0.000000" id="0.000000" type="itemscorept" />
<statentity code="1.000000" id="1.000000" type="itemscorept" />
<statentity code="9" id="omit" type="itemscorept" />
</statentity>
<statentity id="DIFGROUP_TTS" varname="DIFGROUP_TTS" type="popgroup" description="DIFGROUP_TTS">
<statentity code="0.000000" id="0.000000" description="0.000000" samplesize="40501" type="popsubgroup" />
<statentity code="1.000000" id="1.000000" description="1.000000" samplesize="5532" type="popsubgroup" />
</statentity>
</analysisdefs>
<genatt name="xmloutputfile" value="J:\out.xml" />
<analysis creator="ST" description="" level="form" type="classical">
<analysisdata formid="Math G3">
<statentityref id="8243" type="item">
<statval type="OmitCount" value="0.000000" />
<statval type="NotReachedCount" value="43.000000" />
<statval type="PolyserialCorrelation" value="0.644181" />
<statval type="AdjustedPolyserial" value="0.644181" />
<statval type="AverageScore" value="0.223074" se="0.011957" />
<statval type="NCount" value="2609.000000" />
<statval type="StdevItemScore" value="0.416308" />
</statentityref>
</statentityref>
</statentityref>
</analysisdata>
</analysis>
</responseanalyses>
<responsebank findin="J:\outAM.am" sourcetype="AM" id="3M" />
</admin>
</assessment>
I tried
library(xml2)
library(XML)
newdoc <- xpathApply(doc, "/assessment/admin/responseanalyses") I get this error after running this: Error in UseMethod("xpathApply") :
no applicable method for 'xpathApply' applied to an object of class "c('xml_document', 'xml_node')". THis solution was suggested here.
After removing those parent nodes, I would like to have analysisdata node only after removing the assessment/admin/responseanalyses parent node. Desired out is like this below:
<analysisdata formid="Math G3">
<statentityref id="8243" type="item">
<statval type="OmitCount" value="0.000000" />
<statval type="NotReachedCount" value="43.000000" />
<statval type="PolyserialCorrelation" value="0.644181" />
<statval type="AdjustedPolyserial" value="0.644181" />
<statval type="AverageScore" value="0.223074" se="0.011957" />
<statval type="NCount" value="2609.000000" />
<statval type="StdevItemScore" value="0.416308" />
</statentityref>
</statentityref>
</statentityref>
</analysisdata>
Any thoughts?
Thanks!

You could use html_node from rvest library
rvest::html_node(doc, 'analysisdata')

Related

status="NotProcessed" for EnhancedAirBookRQ API

Can anyone help me in this regard, checking with Sabre Soap API's for booking flow. I am getting the failure in EnhancedAirBookRQ response.
I am getting the below response :
<ApplicationResults status="NotProcessed" xmlns="http://services.sabre.com/STL_Payload/v02_01">
<Error type="BusinessLogic" timeStamp="2018-10-01T05:38:45.063-05:00">
<SystemSpecificResults>
<Message code="ERR.SWS.HOST.ERROR_IN_RESPONSE">*NO FARES/RBD/CARRIER</Message>
<Message code="146">*NO FARES/RBD/CARRIER</Message>
</SystemSpecificResults>
</Error>
</ApplicationResults>
Request:
<v3:EnhancedAirBookRQ version="3.2.0" HaltOnError="true" IgnoreOnError="true">
<v3:OTA_AirBookRQ>
<v3:OriginDestinationInformation>
<v3:FlightSegment ArrivalDateTime="2018-11-11T07:38:00" DepartureDateTime="2018-11-11T06:31:00" FlightNumber="6384" NumberInParty="1" ResBookDesigCode="K" Status="NN">
<v3:DestinationLocation LocationCode="BOS" />
<v3:Equipment AirEquipType="E90" />
<v3:MarketingAirline Code="TP" FlightNumber="6384" />
<v3:MarriageGrp Ind="false" />
<v3:OperatingAirline Code="B6" />
<v3:OriginLocation LocationCode="JFK" />
</v3:FlightSegment>
<v3:FlightSegment ArrivalDateTime="2018-11-12T06:00:00" DepartureDateTime="2018-11-11T18:40:00" FlightNumber="218" NumberInParty="1" ResBookDesigCode="K" Status="NN">
<v3:DestinationLocation LocationCode="LIS" />
<v3:Equipment AirEquipType="332" />
<v3:MarketingAirline Code="TP" FlightNumber="218" />
<v3:MarriageGrp Ind="true" />
<v3:OperatingAirline Code="TP" />
<v3:OriginLocation LocationCode="BOS" />
</v3:FlightSegment>
<v3:FlightSegment ArrivalDateTime="2018-11-12T12:20:00" DepartureDateTime="2018-11-12T08:40:00" FlightNumber="6791" NumberInParty="1" ResBookDesigCode="K" Status="NN">
<v3:DestinationLocation LocationCode="LUX" />
<v3:Equipment AirEquipType="73H" />
<v3:MarketingAirline Code="TP" FlightNumber="6791" />
<v3:MarriageGrp Ind="true" />
<v3:OperatingAirline Code="LG" />
<v3:OriginLocation LocationCode="LIS" />
</v3:FlightSegment>
<v3:FlightSegment ArrivalDateTime="2018-11-15T12:25:00" DepartureDateTime="2018-11-15T10:55:00" FlightNumber="3761" NumberInParty="1" ResBookDesigCode="X" Status="NN">
<v3:DestinationLocation LocationCode="OPO" />
<v3:Equipment AirEquipType="73W" />
<v3:MarketingAirline Code="LG" FlightNumber="3761" />
<v3:MarriageGrp Ind="false" />
<v3:OperatingAirline Code="LG" />
<v3:OriginLocation LocationCode="LUX" />
</v3:FlightSegment>
<v3:FlightSegment ArrivalDateTime="2018-11-15T15:30:00" DepartureDateTime="2018-11-15T14:30:00" FlightNumber="1947" NumberInParty="1" ResBookDesigCode="W" Status="NN">
<v3:DestinationLocation LocationCode="LIS" />
<v3:Equipment AirEquipType="AT7" />
<v3:MarketingAirline Code="TP" FlightNumber="1947" />
<v3:MarriageGrp Ind="false" />
<v3:OperatingAirline Code="WI" />
<v3:OriginLocation LocationCode="OPO" />
</v3:FlightSegment>
<v3:FlightSegment ArrivalDateTime="2018-11-15T20:00:00" DepartureDateTime="2018-11-15T17:00:00" FlightNumber="209" NumberInParty="1" ResBookDesigCode="W" Status="NN">
<v3:DestinationLocation LocationCode="JFK" />
<v3:Equipment AirEquipType="332" />
<v3:MarketingAirline Code="TP" FlightNumber="209" />
<v3:MarriageGrp Ind="true" />
<v3:OperatingAirline Code="TP" />
<v3:OriginLocation LocationCode="LIS" />
</v3:FlightSegment>
</v3:OriginDestinationInformation>
</v3:OTA_AirBookRQ>
<v3:OTA_AirPriceRQ>
<!--v3:PriceComparison /-->
<v3:PriceRequestInformation Retain="true">
<v3:OptionalQualifiers>
<v3:PricingQualifiers>
<v3:PassengerType Code="ADT" Quantity="1" />
</v3:PricingQualifiers>
</v3:OptionalQualifiers>
</v3:PriceRequestInformation>
</v3:OTA_AirPriceRQ>
<v3:PostProcessing IgnoreAfter="false" />
<v3:PreProcessing IgnoreBefore="false" />
</v3:EnhancedAirBookRQ>
Checking this test step in soap ui project given by Sabre on their developer portal. Before this, checked for test-steps for create session and low fare search for flights.
Can anyone tell any way to resolve on this. Thanks for any help.
EnhancedAirBookRQ flight details are not correct. Please verify or use search API again to fetch correct details

Disable Telerik Chart Legend by default

How can I make one of the legend of a RadHtmlChart chart display unchecked by default when loading the chart.
Current Chart: current chart
Desired Chart: desired chart
Current telerik asp:
<telerik:RadHtmlChart runat="server" Skin="Bootstrap" ID="RhcIndicadores" Transitions="true">
<Legend>
<Appearance Position="Bottom"></Appearance>
</Legend>
<PlotArea>
<Series>
<telerik:ColumnSeries DataFieldY="Cantidad" Name="Cantidad">
<LabelsAppearance Position="InsideBase" DataFormatString="{0:0}">
<TextStyle Color="White" />
</LabelsAppearance>
<TooltipsAppearance>
<ClientTemplate>Cantidad: #=dataItem.Cantidad# requerimientos.</br>Participación: #= kendo.format(\'{0:N}\', dataItem.Participacion)#%.</br>Rango: #=dataItem.Rango#.</ClientTemplate>
</TooltipsAppearance>
</telerik:ColumnSeries>
<telerik:LineSeries DataFieldY="Participacion" Name="Participación" AxisName="AdditionalAxis">
<Appearance>
<FillStyle BackgroundColor="#ACB72F" />
</Appearance>
<LabelsAppearance DataFormatString="{0:N}%">
<TextStyle Color="#ACB72F" />
</LabelsAppearance>
<TooltipsAppearance DataFormatString="{0:N}%"></TooltipsAppearance>
</telerik:LineSeries>
<telerik:LineSeries DataFieldY="ParetoAcumulado" Name="Pareto Acumulado" AxisName="AdditionalAxisPareto">
<Appearance>
<FillStyle BackgroundColor="#5BC0DE" />
</Appearance>
<LabelsAppearance DataFormatString="{0:N}%" Position="Above">
<TextStyle Color="#5BC0DE" Bold="true" />
</LabelsAppearance>
<TooltipsAppearance DataFormatString="{0:N}%"></TooltipsAppearance>
</telerik:LineSeries>
</Series>
<XAxis DataLabelsField="Rango">
<LabelsAppearance RotationAngle="45"></LabelsAppearance>
<AxisCrossingPoints>
<telerik:AxisCrossingPoint Value="0" />
<telerik:AxisCrossingPoint Value="11" />
</AxisCrossingPoints>
<MajorGridLines Visible="false" />
<MinorGridLines Visible="false" />
</XAxis>
<YAxis Color="#337AB7">
<MajorGridLines Visible="false" />
<MinorGridLines Visible="false" />
</YAxis>
<AdditionalYAxes>
<telerik:AxisY Name="AdditionalAxis" Color="#ACB72F">
<LabelsAppearance DataFormatString="{0:N}%"></LabelsAppearance>
</telerik:AxisY>
<telerik:AxisY Name="AdditionalAxisPareto" Color="#5BC0DE">
<LabelsAppearance DataFormatString="{0:N}%"></LabelsAppearance>
</telerik:AxisY>
</AdditionalYAxes>
</PlotArea>
</telerik:RadHtmlChart>
I myself found the answer, in the desired series it should be indicated Visible="false" and VisibleInLegend="true":
<telerik:LineSeries DataFieldY="ParetoAcumulado" Name="Pareto Acumulado"
Visible="false" VisibleInLegend="true" AxisName="AdditionalAxisPareto">
<Appearance>
<FillStyle BackgroundColor="#5BC0DE" />
</Appearance>
<LabelsAppearance DataFormatString="{0:N}%" Position="Above">
<TextStyle Color="#5BC0DE" Bold="true" />
</LabelsAppearance>
<TooltipsAppearance DataFormatString="{0:N}%"></TooltipsAppearance>
</telerik:LineSeries>

Ajax Control Toolkit HtmlEditorExtender insert image doesn't work

When i try to upload an image firstly it says (Uploaded) but after 2 or 3 second it says (error).
I try to edit my code and my config file but i cant figure out where is the mistake.
I downloaded ajax control toolkit via nuget in vs 2015 community edition.
This is my aspx code
div class="form-group" >
<span class="label label-default"><asp:Literal id="AboutUsLabel" runat="server" />Hakkımızda Türkçe</span><br/>
<%-- <asp:TextBox id="AboutUsText" CssClass="form-control" style="resize:vertical" TextMode="multiline" Columns="50" Rows="20" runat="server" />--%>
<asp:TextBox id="AboutUs" CssClass="form-control" style="resize:vertical" TextMode="multiline" Columns="50" Rows="20" runat="server" />
<ajaxToolkit:HtmlEditorExtender ID="AboutUsEditor" runat="server"
OnImageUploadComplete="AboutUsEditor_ImageUploadComplete"
TargetControlID="AboutUs" EnableSanitization="false">
<Toolbar>
<ajaxToolkit:Undo />
<ajaxToolkit:Redo />
<ajaxToolkit:Bold />
<ajaxToolkit:Italic />
<ajaxToolkit:Underline />
<ajaxToolkit:StrikeThrough />
<ajaxToolkit:Subscript />
<ajaxToolkit:Superscript />
<ajaxToolkit:JustifyLeft />
<ajaxToolkit:JustifyCenter />
<ajaxToolkit:JustifyRight />
<ajaxToolkit:JustifyFull />
<ajaxToolkit:InsertOrderedList />
<ajaxToolkit:InsertUnorderedList />
<ajaxToolkit:CreateLink />
<ajaxToolkit:UnLink />
<ajaxToolkit:RemoveFormat />
<ajaxToolkit:SelectAll />
<ajaxToolkit:UnSelect />
<ajaxToolkit:Delete />
<ajaxToolkit:Cut />
<ajaxToolkit:Copy />
<ajaxToolkit:Paste />
<ajaxToolkit:BackgroundColorSelector />
<ajaxToolkit:ForeColorSelector />
<ajaxToolkit:FontNameSelector />
<ajaxToolkit:FontSizeSelector />
<ajaxToolkit:Indent />
<ajaxToolkit:Outdent />
<ajaxToolkit:InsertHorizontalRule />
<ajaxToolkit:HorizontalSeparator />
<ajaxToolkit:InsertImage />
</Toolbar>
</ajaxToolkit:HtmlEditorExtender>
</div>
.cs file code
protected void AboutUsEditor_ImageUploadComplete(object sender, AjaxFileUploadEventArgs e)
{
string fullPath = "/assets/images/homepage_image/" + e.FileName;
AboutUsEditor.AjaxFileUpload.SaveAs(MapPath("/assets/images/homepage_image/" + e.FileName));
e.PostedUrl = Page.ResolveUrl(fullPath);
}
and this code inside in system.web
<httpHandlers>
<add verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
</httpHandlers>
also this code inside in system.webserver
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
</handlers>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="4294967295"/>
</requestFiltering>
</security>

displayTag pagenation issue -next ,last ,CSV and EXCEL XMLis not working

NEXT ,LAST,CSV,XML
i am not able to use the displaytag property like next,last,CSV ,XML etc
The code goes like this as show below
<link href="resources/displaytag.css" rel="stylesheet" type="text/css" media="all" />
<link href="resources/alternative.css" rel="stylesheet" type="text/css" media="all" />
<body>
<form:form action="date" method="get" >
<display:table name="billingLogReportPojoList" id="billingLogTable"
export="true" class="its" pagesize="10" >
<display:setProperty name="basic.empty.showtable" value="true"></display:setProperty>
<display:setProperty name="export.pdf.decorator" value="org.displaytag.sample.decorators.ItextTotalWrapper" />
<display:setProperty name="export.pdf.filename" value="billingLogReport.pdf" />
<display:setProperty name="export.rtf.decorator" value="org.displaytag.sample.decorators.ItextTotalWrapper" />
<display:setProperty name="export.rtf.filename" value="billingLogReport.rtf" />
<display:setProperty name="export.excel.decorator" value="org.displaytag.sample.decorators.HssfTotalWrapper" />
<display:setProperty name="export.excel.filename" value="billingLogReport.xls" />
<display:setProperty name="export.csv" value="true" />
<display:setProperty name="export.xml" value="true" />
<display:column title="ID" property="pnrId" />
<display:column title="Request Date Time" property="requestDateTime" format="{0,date,dd-MM-yyyy}"/>
<display:column title="Status" property="status" />
<display:column title="Trace No" property="traceNo" />
<display:column title="Reference No" property="referenceNo" />
<display:column title="PNR No" property="pnrNo" />
<display:column title="PNR Status" property="pnrStatus" />
<display:column title="Amount" property="amount" />
<display:column title="Ticket No." property="ticketNo"/>
<display:column title="Ticket Value" property="ticketValue" />
<display:column title="Passenger Type" property="passengerType" />
<display:column title="Given Name" property="givenName" />
<display:column title="Surname" property="surname" />
<display:column title="Mobile No." property="mobileNo" />
<display:column title="Email" property="email"/>
<display:column title="Taxes" property="taxes" style="white-space: nowrap;"/>
</display:table>
</div>
</form:form>
</div>
</body>
</html>
When i am clicking on like CSV it is not generating the file and giving error like 404
you have to set requestURI parameter in <display:table />!
if you don't set it properly when you click on the link, the page will be initialized without any arguments!
here is a sample of correct code:
<display:table name="appUserAttendanceList" id="assetUserAttendance" htmlId="thetable"
class="tableBorder" defaultorder="ascending" sort="list"
pagesize="10" excludedParams="method" export="true"
requestURI="/assetUserManagement.do?method=setAttendanceFromClient">

WHy is awesome_print gem showing <br /> in rspec output

I'm getting this output from ap, in my rspec test
"line1"<br />
"line2"<br />
"city"<br />
"state"<br />
"zip"<br />
"country"<br />
It is not because of the :html option, because when that's on it looks like:
<pre><kbd style="color:brown">"line1"</kbd></pre><br />
<pre><kbd style="color:brown">"line2"</kbd></pre><br />
<pre><kbd style="color:brown">"city"</kbd></pre><br />
<pre><kbd style="color:brown">"state"</kbd></pre><br />
<pre><kbd style="color:brown">"zip"</kbd></pre><br />
<pre><kbd style="color:brown">"country"</kbd></pre><br />

Resources