2013-07-09 2 views
0

최신 빙 API 업데이트로 변경된 사항을 찾을 수 없습니다. 나는 잠시 동안 내 앱을 업데이트하지 않았고 정규 표현식이 IRouteService 응답에서 더 이상 태그를 제거하지 않았습니다!Bing API IRouteService 응답에서 <VirtualEarth> 태그를 제거하십시오.

//Remove all Bing Maps tags around keywords. 
Regex regex = new Regex("<[/a-zA-Z:]*>", RegexOptions.IgnoreCase | RegexOptions.Multiline); 
textBlock1.Text = regex.Replace(directions.ToString(), string.Empty); 

예기치 않은 결과 : 분명 뭔가가 너희들에 튀어 나와있는 경우

Leg #1 
1. 15.034 Head <VirtualEarth:span class="heading">northeast</VirtualEarth:span>. 
2. 8.4 Turn <VirtualEarth:TurnDir>left</VirtualEarth:TurnDir> 
3. 0 You will reach your destination . The destination is on your left. 

예상 결과

Leg #1 
1. 15.034 Head northeast. 
2. 8.4 Turn left 
3. 0 You will reach your destination . The destination is on your left. 

궁금 해서요! 보고 주셔서 감사합니다.

답변

2

문자 클래스에서 ", = 문자가 누락되었습니다. 태그의 속성에 포함되어 있습니다. 이 옵션을 사용합니다 :

Regex regex = new Regex("<[/a-zA-Z:\"' =]+>", RegexOptions.IgnoreCase | RegexOptions.Multiline); 

편집 : 내 첫 번째 게시물은 내가 대신 " 문자로 테스트하는 데 사용되는 ' 문자 포함 - 나는 코드가 업데이트합니다.

+1

아마도''''와'''를 모두 포함하는 것이 가장 좋습니다. XML이 두 가지 방법으로 돌아 오는 것을 보았습니다. – Bobson

+1

@Bobson : 동의! :) 그것을 다시 추가했습니다. –

+0

Michael Bray와 Bobson에게 감사드립니다. – clamchoda