Professional IronPython


Type  print sys.path and press Enter. You should see the new path added to the list. 5



Download 20,35 Mb.
Pdf ko'rish
bet287/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   283   284   285   286   287   288   289   290   ...   453
4.
Type 
print sys.path
and press Enter. You should see the new path added to the list.
5.
Type 
import XMLUtil
and press Enter. This step makes the 
XMLUtil.py
module available 
for use.
6.
Type 
dir(XMLUtil)
and press Enter. You see the list of methods available in 
XMLUtil
(as 
shown in Figure 13-3), which includes the 
Walk()
method used in the example.
548592c13.indd 276
2/24/10 12:48:57 PM
www.finebook.ir


Using XMLUtil
 

 
277
FIgURE 13-3: 
The Walk() method makes viewing XML data easier.
Using the XMLUtil Module to View XML Data
As previously mentioned, the 
XMLUtil.py
file isn’t anything so advanced that you couldn’t put it 
together yourself, but it’s an interesting module to work with and use. Listing 13-2 shows a short 
example of how you could use this module in an application.
LISTINg 13-2: 
 Walking an XML document using XMLUtil
# Add the path required to import xmlutil. 
import sys 
sys.path.append(‘C:/Program Files/IronPython 2.6/Tutorial’)
# Import xmlutil to access the Walk() function.
import xmlutil
# Import clr to add references.
import clr
# Add the required reference.
clr.AddReference(‘System.Xml’)
# Import the System.Xml classes.
from System.Xml import *
# Create a document.
XMLDoc = XmlDocument()
# Load the XML data.
XMLDoc.Load(‘Test.XML’)
# Walk the file contents. 
print ‘Contents of Test.XML’ 
for Node in xmlutil.Walk(XMLDoc):
print ‘\nName:’, Node.Name
print ‘Value:’, Node.Value
continues
548592c13.indd 277
2/24/10 12:48:58 PM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   283   284   285   286   287   288   289   290   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish