2014-12-19 1 views
0

그런 모호한 질문을 던져서 죄송합니다. 나는 일하기 위해 서둘 렀습니다. 내 잘못, 사과.coldfusion 및 mysql에 대한 XML

전체 질문입니다.

크기가 7MB 인 xml 파일이 있는데 정보를 추출하여 mysql에 추가하고 추출 된 정보로 새 테이블을 만들고 싶습니다.

다음은 xml 파일의 구조입니다 (원본 파일의 속성은 1185 개가 넘음).이 예제에는 하나만 있습니다.

내가 ColdFusion에서와 공급에서 필요하지 않은 요소를 제거 할 수 방법을 알고 다음 MySQL의에서 테이블에 필수 필드를 가져올 것

<?xml version="1.0" encoding="UTF-8"?> 
<root> 
<properties> 
<property> 
<details> 
    <propertyid>112</propertyid> 
    <name>Spain, Costa del Sol, Marbella, Capanes del Golf Apartment- 5* hotel facilities</name> 
    <reference>2360</reference> 
    <price>376242</price> 
    <pricetype id="4">N/A</pricetype> 
    <status id="3">For Sale</status> 
    <description> 
     <p>Capanes del Golf is one of the most exclusive project in Costa del Sol at this time. The complex with luxurious apartments is located near the road to Benahavis and just a few minutes away from the coast.</p> 
     <p>Positioned at the very heart of the New Marbella Club Golf Course (El Higueral Golf), its location is unique as it is totally surrounded by the course. As well as its stunning location at the heart of the course, the complex also enjoys more than 50.000 m2 of carefully landscaped Mediterranean gardens with water areas, swimmingpools as well as a private Club Social with Spa and fitness.</p> 
     <p>All of the apartments at Capanes del Golf have a golf share to the New Marbella Club Golf Course included in the sales price, this allows the client full access to the golf course surrounding the project. Capanes del Golf is a project not just to be lived but also enjoyed as a home.</p> 
     <p> 
      <strong>Additional Features</strong> 
     </p> 
     <p>5 * Hotel facilties<br />Gym<br />Health spa available on site<br />Established on a Golf resort</p> 
    </description> 
    <levels>0</levels> 
    <bedrooms>2</bedrooms> 
    <bathrooms>1</bathrooms> 
    <areacovered>189</areacovered> 
    <areaplot>0</areaplot> 
    <areaveranda>0</areaveranda> 
    <areagarden>0</areagarden> 
    <promote>0</promote> 
    <sleeps>0</sleeps> 
    <deliverydate /> 
    <googlemapurl /> 
    <latitude /> 
    <longitude /> 
    <mapzoom /> 
    <mapactive>0</mapactive> 
    <investment /> 
    <ownernotes /> 
    <dateadded /> 
    <dateupdated>01/01/2013</dateupdated> 
    <sortweight>0</sortweight> 
    <urlalias>spain-costa-del-sol-marbella-hotel-facilities-1</urlalias> 
    <url>http://127.0.0.1/properties-for-sale/spain-costa-del-sol-marbella-hotel-facilities-1</url> 
</details> 
<location> 
    <country id="27" urlalias="spain">Spain</country> 
    <district id="52" urlalias="costa-del-sol">Costa del Sol</district> 
    <location id="929" urlalias="marbella">Marbella</location> 
</location> 
<types> 
    <type id="8" urlalias="apartment-flat">Apartment-Flat</type> 
</types> 
<categories /> 
<features /> 
<images> 
    <imageurl>http://127.0.0.1/media/property-images/spain-costa-del-sol-marbella-hotel-facilities_full_11.jpg</imageurl> 
    <imageurl>http://127.0.0.1/media/property-images/spain-costa-del-sol-marbella-hotel-facilities_full_12.jpg</imageurl> 
    <imageurl>http://127.0.0.1/media/property-images/spain-costa-del-sol-marbella-hotel-facilities_full_13.jpg</imageurl> 
    <imageurl>http://127.0.0.1/media/property-images/spain-costa-del-sol-marbella-hotel-facilities_full_14.jpg</imageurl> 
    <imageurl>http://127.0.0.1/media/property-images/spain-costa-del-sol-marbella-hotel-facilities_full_15.jpg</imageurl> 
    <imageurl>http://127.0.0.1/media/property-images/spain-costa-del-sol-marbella-hotel-facilities_full_16.jpg</imageurl> 
</images> 
</property> 
</properties> 
</root> 

필자는 JSON 형식으로 출력 데이터를 시도 아래 레이몬드 캠든하여 코드를 사용하여 ColdFusion에서 메신저 사용 :

<cfset cachedJSON = cacheGet("jsonstr")> 
<cfif isNull(cachedJSON)> 

<cfset xmlFile = expandPath("./xml/poj.xml")> 
<cfset xmlData = xmlParse(xmlFile)> 

<cfscript> 
function xmlToStruct(xml x) { 
var s = {}; 

if(xmlGetNodeType(x) == "DOCUMENT_NODE") { 
s[structKeyList(x)] = xmlToStruct(x[structKeyList(x)]); 
} 

if(structKeyExists(x, "xmlAttributes") && !structIsEmpty(x.xmlAttributes)) { 
s.attributes = {}; 
for(var item in x.xmlAttributes) { 
s.attributes[item] = x.xmlAttributes[item]; 
} 
} 

if(structKeyExists(x, "xmlChildren")) { 
for(var i=1; i<=arrayLen(x.xmlChildren); i++) { 
if(structKeyExists(s, x.xmlchildren[i].xmlname)) { 
if(!isArray(s[x.xmlChildren[i].xmlname])) { 
var temp = s[x.xmlchildren[i].xmlname]; 
s[x.xmlchildren[i].xmlname] = [temp]; 
} 
arrayAppend(s[x.xmlchildren[i].xmlname], xmlToStruct(x.xmlChildren[i])); 
} else { 
s[x.xmlChildren[i].xmlName] = xmlToStruct(x.xmlChildren[i]); 
} 
} 
} 

return s; 
} 

cachedJSON = serializeJSON(xmlToStruct(xmlData)); 

</cfscript> 

<cfset cachePut("jsonstr", cachedJSON)> 

</cfif> 

<cfcontent reset="true" type="application/json"><cfoutput>#cachedJSON#</cfoutput> 

하는 것은 기본적으로 이것은 워드 프레스 시스템에 의해 생성 된 XML 피드를 받고 부동산 웹 사이트에 대한 것입니다. 데이터는 jquery 함수를 사용하여 xml을 구문 분석하고 coldfusion serializeJSON 함수를 사용하여 ok를 출력합니다. 나는 XML의 구조에있는 노드에 혼란스러워진다. MySQL의 테이블에 모든 것을 추가하고 데이터베이스의 속성을 업데이트하기 위해 하루에 한 번 업데이트를 실행하는 것이다. 내 coldfusion과 자바 지식이 가장 위대하지 않습니다 그래서 만약 내가 여기에 일을 어렵게 만들고있어 용서해주십시오. 내가 데이터베이스에 모든 것을 저장하려는 이유는 내가 그 필드에서 검색 기능을 만들 수 있도록 내가 국가/지역/도시/마을 테이블, 통화 테이블, 속성 유형 테이블 등을 가질 수 있습니다.

나는 navicat 가져 오기 기능을 사용하여 mysql로 ​​XML을 가져 오려고하는데, 필요한 정보가 태그에있는 방식대로 작동하지 않습니다. 내가 여기서 의미를 갖기를 바랍니다. 나는이 모든 정보를 데이터베이스에 저장하고 피드에서 곧바로 속성을 표시 할 필요가 있다는 것을 의미합니까?

+1

지금까지 시도한 것을 보여줄 수 있습니까? 그래서 우리는 구체적인 문제에 당신을 도울 수 있습니다. –

+0

나는 그 사람이 나의 "대답"에 충고하는 행동을하기 때문에이 질문을 끝내기 위해 투표를 연기하고있다. –

+0

죄송합니다. 몇 분 안에 모든 것을 추가 할 예정입니다. 애매하게 여겨지기 때문에 미안합니다. hvae 시간을 돌 렸습니다. – johnnyc0506

답변

0

에 대한 노력을 나타내지 않으므로 CFML에서이 작업을 수행하는 방법을 찾으십시오. 그래서 저는 자신의 연구가 제안한 것처럼이 답을 피상적으로 보게 될 것입니다.

ColdFusion은 XML 심문 및 조작을 지원합니다. 여기에서 시작하십시오 : "Using XML and WDDX". WDDX에 관한 내용은 특별히 무시하고 모든 XML 가능성을 읽고 실험하고 이해하십시오. 이 기능에 특히주의하십시오 : xmlSearch(), xmlTransform(). 또한 섹션 "Modifying a ColdFusion XML object".

당신이 묻는 것을 위해, 문서를 읽고 그에 대한 행동을 제안하면 도움이 될 것입니다.

당신은 그렇게하고 뭔가을 시도하고 여전히 문제가있는 경우 : 코드를 게시 - 또는 아래로 깎았 생식 경우 그냥 문제를 보여줍니다 것을 (이 읽기 : "Short, Self Contained, Correct (Compilable), Example"를, 그리고 워드 프로세서 나 링크 그 안에) - 더 직접적인 질문을하십시오.

당신이이 과정을 얼마나 멀리하고 있는지 나타내지 않으므로 질문에 대답하는 것이 얼마나 좋은지 잘 모릅니다. 그래서 내가 이미 가지고있는 어떤 것에 조언을 제공하는 데 시간을 낭비하게 될지 모르겠습니다. 시도/이해/등등. 나는 우리 시간 중 낭비하고 싶지 않다. (나는 자신의 시간 낭비에 대해 더 염려하지만, 나는 인정할 것이다.)