You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: labs/coding-201-parsing-xml/1.md
+17-19Lines changed: 17 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,6 @@
1
1
# Coding 201: Parsing XML using Python
2
2
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).
5
4
6
5
## Objectives
7
6
@@ -20,49 +19,48 @@ For this lab, use Python 3.4+. If you are on a DevNet Zone station, the correct
20
19
python --version
21
20
```
22
21
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.
24
25
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.
26
27
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`:
- Importing the required `Request` and `urlopen` libraries.
42
41
- Constructing a request to the CMX URI.
43
42
- Adding basic authentication to your Request.
44
43
- 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 <ahref="https://github.com/CiscoDevNet/coding-skills-sample-code/blob/master/coding201-parsing-xml/get-ap-xml-1.py"target="_blank">here</a>.
47
47
48
-
4. Save the `get-ap-xml.py` file. To download or review the current code, you can get it from GitHub <ahref="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:
51
49
```
52
50
cd %USERPROFILE%\Desktop
53
51
```
54
52
If you are using OS X, enter the following command into the terminal to move to your computer:
55
53
```
56
54
cd ~/Desktop
57
55
```
58
-
6.In the command prompt window, enter the following command:
56
+
In the command prompt window, enter the following command:
59
57
```
60
58
python get-ap-xml.py
61
59
```
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.
0 commit comments