안녕하세요 저는 R 및 XML 파일을 처음 사용합니다. 내가 좋아하는 몇 가지 옵션 시도중첩 된 XML을 데이터 프레임에서 R
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<PrepareDataByClientResponse xmlns="urn:HM-schema">
<PrepareDataByClientResult>
<READOUT>
<SerialNumber>1728527</SerialNumber>
<Date>1510505992000</Date>
<Type>1</Type>
<Value>78.2</Value>
<Status>OK</Status>
</READOUT>
<READOUT>
<SerialNumber>1728527</SerialNumber>
<Date>1510509592000</Date>
<Type>1</Type>
<Value>76.87</Value>
<Status>OK</Status>
</READOUT>
<READOUT>
<SerialNumber>1728527</SerialNumber>
<Date>1510513192000</Date>
<Type>1</Type>
<Value>75.61</Value>
<Status>OK</Status>
</READOUT>
<READOUT>
<SerialNumber>e2ddeed13b4cc4d132f8c6a67d67eed3</SerialNumber>
<Date>4531528776000</Date>
<Type>3</Type>
<Value>230.68</Value>
<Status>OK</Status>
</READOUT>
</PrepareDataByClientResult>
</PrepareDataByClientResponse>
</soap:Body>
</soap:Envelope>
:
가 나는 dataframe에이 XML SOAP 응답을 얻으려고 SO 및 기타 Google 검색에서 광범위한 연구 후xmlout <- do.call(rbind, xpathApply(xmldoc,'//soap:Envelope/soap:Body/PrepareDataByClientResponse', xmlToDataFrame))
xmlout <- as.data.frame(t(xpathSApply(xmldoc,"//readout",function(x) xmlSApply(x,xmlValue))))
xmlout <- as.data.frame(t(xmlSApply(xmldoc["/PrepareDataByClientResponse/PrepareDataByClientResult/READOUT"],xmlAttrs)),stringsAsFactors=FALSE)
xmlout <- ldply(xmlToList(xmldoc), data.frame)
을, I 원하는 결과를 얻을 수 없습니다. 내가 얻을 수있는 것은 하나의 행과 다른 열의 모든 관측치가있는 데이터 프레임입니다.
SerialNumber Date Type Value Status
1 1728527 1510505992000 1 78.2 OK
2 1728527 1510509592000 1 76.87 OK
3 1728527 1510513192000 1 75.61 OK
작업 테이블의 종류를 얻을 수있는 방법이 있나요 :
내가 좋아하는 READOUTS의 표를 얻으려고?
미리 감사드립니다.
신난다, 그것은 마법처럼 일했다. 설명은 나와 같은 초보자에게도 매우 유용했습니다. 고맙습니다! –
@JavierNevado - 듣고 기꺼이 도와 드리겠습니다. 해피 코딩! – Parfait