2012-06-26 1 views
0

값 :다음은 기본적으로 그냥 XML 파일입니다 큰 FXG 파일에서 코드의 단지 snipplet입니다

<RichText x="14.1655" y="46.5674" columnGap="18" columnCount="1" textAlign="left" fontFamily="Bootstrap" color="#53836A" whiteSpaceCollapse="preserve" width="202.712" height="13.334" s7:caps="none" s7:colorName="" s7:colorValue="#B24FA41C" s7:colorspace="cmyk" s7:elementID="line1" s7:fill="true" s7:fillOverprint="false" s7:firstBaselineOffset="ascent" s7:joints="miter" s7:maxFontSize="12" s7:miterLimit="10" s7:referencePoint="inherit" s7:rowCount="1" s7:rowGap="18" s7:rowMajorOrder="true" s7:stroke="false" s7:strokeOverprint="false" s7:warpBend="0.5" s7:warpDirection="horizontal" s7:warpHorizontalDistortion="0" s7:warpStyle="none" s7:warpVerticalDistortion="0" s7:weight="1" ai:aa="2" ATE:C_charRotation="0" ATE:C_horizontalScale="1" ATE:C_kerning="metric" ATE:C_verticalScale="1" ATE:P_autoHyphenate="true" ATE:P_consecutiveHyphenLimit="0" ATE:P_hyphenateCapitalized="true" ATE:P_hyphenatedWordSize="6" ATE:P_hyphenationPreference="0.5" ATE:P_hyphenationZone="36" ATE:P_postHyphenSize="2" ATE:P_preHyphenSize="2" d:userLabel="id:line1"> 
    <content><p><span>Address Line 1</span></p></content> 
</RichText> 

XML 파일의 노드 수있다 그 비슷한 구조를 가지고있다. 그러나 각 RichText 노드에는이 경우에 고유 한 요소 ID 인 s7:elementID="line1"이 있습니다. 내가 잡을 수있는 방법을 PHP 또는 자바 스크립트를 사용

, 다음 중 하나를

  1. 텍스트 "주소 입력란 1"
  2. 내용, 페이지, 스팬 태그를 포함한 전체 라인

내가 지정하는 경우 elementID 콘텐츠를 원하십니까?

XML에 익숙하지 않아서 이것이 가능한지 확실하지 않습니다.

답변

1

부하의 객체로 XML은 : simplexml_load_string()

다음 서식있는 텍스트 요소를 얻기 위해 그 객체에 ->xpath('RichText')를 사용합니다.

당신이 도스 요소에 ->asXML()를 사용하는 경우,

당신이 "<content><p><span>Address Line 1</span></p></content>"

을 얻을 항상 "<content><p><span>" 그 것이다?

당신은 내가 항상 내용, P, 스팬 태그가있을 것이라고 생각 (string) $RichText->content[0]->p[0]->span[0]

+0

를 사용할 수 있습니다. – thindery

+0

은 요소를 검색 할 RichText 노드를 정확하게 지정하는 방법입니다. 일반적으로 각 파일에는 5 또는 6 개의 RichText 노드가 있습니다. RichText 노드의 elementID를 기반으로 특정 항목을 가져와야합니다. 그게 가능합니까, 어떻게 든 id를 지정하면? – thindery

+0

xpath에 대해 더 자세히 읽고, ('RichText [id = testid]') –