我正在使用.find方法來獲取xml標記的值。在我的xml中,如果xmltag重複,它會給我所有標記的值。 例在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,我用下面的代碼來獲取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.
}
有人可以在這方面幫助我嗎?
由於德里克,問題解決了。 – Manish 2014-10-17 04:40:10