Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I write this xpath.

Status
Not open for further replies.

ozatmaca

Programmer
Feb 10, 2009
3
hi.
my questions very easy. but I am untrained(xml).
I have xml file like this.
<items>
<aaa a1="2" a2="fsfjsf">
<bbb b1="4" b2="dbgh">
<ccc c1="6" c2="gdpo" />
<ccc c1="65" c2="i?lbmk?u" />
...........
...........
</bbb>
</aaa>
<aaa..........
.........
.........
........
</items>

I want to obtain a4 = "45" and b5="99" (for ccc).
Can you help me.
how can I write xpath query
 
You show many details except a4 and b5. Why is that? Where are they?
 
this code is example. Orijinal code is very long. (20000 rows)
orijinal code is diffirent from this code but costruction is same.

orijinal code

<okullar>
<il kod="1" ad="ADANA">
<ilce kod="38" ad="ALADA?">
<okul kod="623" ad="Aktepe Köyü ?.Ö" />
<okul kod="6136" ad="K?cak ?.Ö" />
<okul kod="6565" ad="Kökez ?.Ö" />
<okul kod="8215" ad="P?nar Madencilik L." />
<okul kod="16" ad="100.y?l Sar?sakal ?.Ö" />
</ilce>
<ilce kod="159" ad="CEYHAN">
<okul kod="6565" ad="Kökez ?.Ö" />
<okul kod="16" ad="100.y?l Sar?sakal ?.Ö" />
<okul kod="623" ad="Aktepe Köyü ?.Ö" />
<okul kod="67" ad="23 Nisan ?.Ö" />
<okul kod="6778" ad="Kuzucak ?.Ö" />
<okul kod="10755" ad="Ye?ildam L." />
</ilce>
<ilce kod="309" ad="FEKE">
<okul kod="3796" ad="Feke L." />
<okul kod="6778" ad="Kuzucak ?.Ö" />
<okul kod="5301" ad="?ncirci ?.Ö" />
<okul kod="9078" ad="Suphandere ?.Ö" />
</ilce>
<il kod="2" ad="ADIYAMAN">
<ilce kod="117" ad="BESN?">
<okul kod="5301" ad="?ncirci ?.Ö" />
<okul kod="530" ad="Akdurak ?.Ö" />
<okul kod="623" ad="Aktepe Köyü ?.Ö" />
<okul kod="10608" ad="Yaz?karakuyu ?.Ö" />
<okul kod="10873" ad="Yolduzu ?.Ö" />
</ilce>
<ilce kod="159" ad="CEYHAN">
<okul kod="5301" ad="?ncirci ?.Ö" />
<okul kod="10755" ad="Ye?ildam L." />
<okul kod="623" ad="Aktepe Köyü ?.Ö" />

</ilce>
</il>
........
........
........
.......
.......(20000 rows)
</okullar>

for example.
I want to select "bold rows". (il kod = "2" and ilce kod = "159")
 
[0] I appreciate that the document is long (or short for that matter); but if you want to show an abridged example (that is the preferrable idea as we are not voyeur), you have to understand that you must show it preserving the "generic" structure and leave the incidental thing to the caprice harmlessly. That's how people can answer to your call. If you destroy the generic structure, that is wasting everybody's time, yours included.

[1] I suppose before the <il kod='2'...> part begin, you miss the close tag of il, </il>. (That affects the structure, and it matters.)

[2] The xpath can be this.
[tt] /okula/il[@kod='2']/ilce[@kod='159'][/tt]
 
erratum
typo: okular should be read okullar.
[tt] /okul[red]l[/red]a/il[@kod='2']/ilce[@kod='159'][/tt]
 
thanks.
I forgot close tag (il), while I write to here.
I haven't wiret all code. because I tried to prepare a few days this document. I have collection all school(okul) in Turkey (Whic city(il) , which district (ilçe)).
thanks for answer.
I think, this xpath right for me.
I'm sorry. My english very poor.
 
Don't worry about it though, your English or mine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top