.find 메소드를 사용하여 xml 태그의 값을 가져옵니다. xmltag가 반복되면 내 XML에서 모든 태그 값을 제공합니다. 예 언급 XML의jQuery에서 find 메소드를 사용할 때 여러 태그 값 가져 오기
<Response>
<Result>0</Result>
<Message>Tenant Information fetched for tenantID=1</Message>
<Data>
<Tenants>
<row>
<TenantID>1</TenantID>
<TenantTypeID>1</TenantTypeID>
<CardCode>CLINSH0184</CardCode>
<CustomerName>S. H. Pitkar Orthotools Pvt Ltd</CustomerName>
<CustomerGroup>VAT Customer</CustomerGroup>
<ServiceContract>69</ServiceContract>
<SUserID>S0004493123</SUserID>
<ContactPerson>Nupur Pitkar</ContactPerson>
<Phone1>123</Phone1>
<Phone2>456</Phone2>
<Mobile>789</Mobile>
<Email>[email protected]</Email>
<StartDate>2014-01-01T00:00:00</StartDate>
<EndDate>2015-01-01T00:00:00</EndDate>
<Active>1</Active>
<B1Version>8.82</B1Version>
<PatchLevel>12</PatchLevel>
<SqlVersion>2008</SqlVersion>
<ServiceURL>http://localhost:8932/CRMService.asmx</ServiceURL>
<DataBaseName>WTS</DataBaseName>
<ExpiredMessage>Subscription to this account is expired. Please contact System Administrator</ExpiredMessage>
<ExpirationMessage>Subscription to this account will expire soon. Please contact System Administrator</ExpirationMessage>
<WarningDays>3</WarningDays>
<logo>CLINSH0184.jpg</logo>
<LicenseDetails>
<row>
<ItemCode>SaaS-CRM-Sales</ItemCode>
<ItemName>SaaS - CRM Module-Sales</ItemName>
<StartDate>2014-07-15T00:00:00</StartDate>
<EndDate>2014-08-15T00:00:00</EndDate>
<License>1</License>
</row>
<row>
<ItemCode>SaaS-CRM-Purchase</ItemCode>
<ItemName>SaaS - CRM Module-Purchase</ItemName>
<StartDate>2014-07-15T00:00:00</StartDate>
<EndDate>2014-08-15T00:00:00</EndDate>
<License>2</License>
</row>
<row>
<ItemCode>SaaS-CRM-Service</ItemCode>
<ItemName>SaaS - CRM Module-Service</ItemName>
<StartDate>2014-07-15T00:00:00</StartDate>
<EndDate>2014-08-15T00:00:00</EndDate>
<License>3</License>
</row>
</LicenseDetails>
</row>
</Tenants>
</Data>
, 나는 XML 태그의 값을 얻기 위해 코드 아래 사용합니다.
var bindName='Response Data Tenants row StartDate';
$xmlNode = $xml.find(bindName);
if ($xmlNode != null) {
var value = $xmlNode.text();
//do some thing with code.
//here I am geting all value of xml tag start with 'StartDate'
//I am expecting value of only single node specified in bindName variable.
}
아무튼이 컨텍스트에서 나를 도울 수 있습니까?
덕분에 데릭, 문제 해결 :
단일
Tenant
내부에 여러Tenants
또는 여러row
섹션이있는 경우 당신은 여전히 하나 개 이상의 결과를 얻을 수 있으며,이.each()
를 사용하여 반복해야 있음을 유의하십시오. – Manish