Skip to content

Commit 0ad34d2

Browse files
authored
Since the Sandbox is unavailable, revise as example
Start to address Issue # 106 CiscoDevNet/learning-labs-issues#106
1 parent a9c936a commit 0ad34d2

File tree

1 file changed

+17
-19
lines changed
  • labs/coding-201-parsing-xml

1 file changed

+17
-19
lines changed

labs/coding-201-parsing-xml/1.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Coding 201: Parsing XML using Python
22

3-
In this Learning Lab, you learn the basics of parsing XML content using Python. You will query [CMX Mobility Services](https://developer.cisco.com/site/cmx-mobility-services/ "CMX Mobility Services") data for available access points and put their names into a simple list for display. To learn more about CMX, review the [Mobility Services Engine (MSE) Learning Lab](lab/cmx/step/1).
4-
3+
In this Learning Lab, you learn the basics of parsing XML content using Python. The example runs a query on [CMX Mobility Services](https://developer.cisco.com/site/cmx-mobility-services/ "CMX Mobility Services") data for available access points and put their names into a simple list for display. To learn more about CMX, review the [Mobility Services Engine (MSE) Learning Lab](lab/cmx/step/1).
54

65
## Objectives
76

@@ -20,49 +19,48 @@ For this lab, use Python 3.4+. If you are on a DevNet Zone station, the correct
2019
python --version
2120
```
2221

23-
## Step 1: Make an HTTP REST call with Python
22+
## Example: Make an HTTP REST call with Python
23+
24+
> **Note**: The example uses a CMX MSE Server, where you would need to have access to one and substitute here.
2425
25-
To get started, create a simple Python script that sends an HTTP request to the CMX MSE Server.
26+
To get started, this walk-through shows creating a simple Python script that sends an HTTP request to a CMX MSE Server.
2627

27-
1. Open the text editor and create a file named `get-ap-xml.py`.
28-
2. Save `get-ap-xml.py` to the computer.
29-
3. Within the text editor add the following lines to `get-ap-xml.py`:
28+
Example `get-ap-xml.py` file:
3029
```
3130
from urllib.request import Request, urlopen
32-
req = Request('https://cmxlocationsandbox.cisco.com/api/contextaware/v1/maps/info/DevNetCampus/DevNetBuilding/DevNetZone')
31+
req = Request('https://<ServerURLorIPAddress>/api/contextaware/v1/maps/info/DevNetCampus/DevNetBuilding/DevNetZone')
3332
req.add_header('Authorization', 'Basic bGVhcm5pbmc6bGVhcm5pbmc=')
3433
response = urlopen(req)
3534
responseString = response.read().decode("utf-8")
3635
print(responseString)
3736
response.close()
3837
```
3938

40-
This snippet:
39+
This snippet shows:
4140
- Importing the required `Request` and `urlopen` libraries.
4241
- Constructing a request to the CMX URI.
4342
- Adding basic authentication to your Request.
4443
- Opening the request and getting a response back from the CMX URI.
45-
- Parsing the response as a string and printing it to the console.<br/>
46-
<br/>
44+
- Parsing the response as a string and printing it to the console.
45+
46+
To download or review the current code, you can get it from GitHub <a href="https://github.com/CiscoDevNet/coding-skills-sample-code/blob/master/coding201-parsing-xml/get-ap-xml-1.py" target="_blank">here</a>.
4747

48-
4. Save the `get-ap-xml.py` file. To download or review the current code, you can get it from GitHub <a href="https://github.com/CiscoDevNet/coding-skills-sample-code/blob/master/coding201-parsing-xml/get-ap-xml-1.py" target="_blank">here</a>.
49-
5. Open a command prompt.<br/><br/>
50-
If your are using the Windows OS, enter the following command into the command prompt window to move to your computer:
48+
If you are using Windows, enter the following command into the command prompt window to move to your computer:
5149
```
5250
cd %USERPROFILE%\Desktop
5351
```
5452
If you are using OS X, enter the following command into the terminal to move to your computer:
5553
```
5654
cd ~/Desktop
5755
```
58-
6. In the command prompt window, enter the following command:
56+
In the command prompt window, enter the following command:
5957
```
6058
python get-ap-xml.py
6159
```
62-
Note: On OS X, to use Python 3.4, you may need to enter `python3.4 get-ap-xml.py`. If you get errors, verify the version of python and double-check the code.
63-
<br/>
64-
<br/>
65-
7. When you run the Python script, the terminal should display a screen full of XML data.
60+
61+
> **Note**: On OS X, to use Python 3.4, you may need to enter `python3.4 get-ap-xml.py`. If you get errors, verify the version of python and double-check the code.
62+
63+
When you run the Python script, the terminal displays a screen full of XML data.
6664

6765
![](assets/images/xml-output.png)
6866

0 commit comments

Comments
 (0)