INTRODUCTION TO SERVER-SIDE XML in Font

Draw Data Matrix in Font INTRODUCTION TO SERVER-SIDE XML

CHAPTER 11 INTRODUCTION TO SERVER-SIDE XML
Data Matrix Creator In None
Using Barcode printer for Font Control to generate, create ECC200 image in Font applications.
www.OnBarcode.com
Encoding Code-39 In None
Using Barcode generation for Font Control to generate, create USS Code 39 image in Font applications.
www.OnBarcode.com
</td> </tr> </table> </form> Notice that I ve also passed through the id in a hidden form field. Again, I haven t added validation to simplify the code. Once the user changes the details of a DVD, the form submits to the page editDVDAction.php: < php $id = $_POST['txtID']; $title = $_POST['txtTitle']; $format = $_POST['txtFormat']; $genre = $_POST['txtGenre']; $dom = new DomDocument(); $dom->load("dvd.xml"); $path = "/library/DVD[@id=" . $id . "]"; $xPath = new domxpath($dom); $selectedNode = $xPath->query($path)->item(0); foreach ($selectedNode->childNodes as $child) { if ($child->nodeName == "title") { $child ->firstChild->nodeValue = $title; } elseif ($child->nodeName == "format") { $child->firstChild->nodeValue = $format; } elseif ($child->nodeName == "genre") { $child->firstChild->nodeValue = $genre; } } $dom->save("dvd.xml"); > <html> <head> <link href="styles.css" type="text/css" rel="stylesheet" /> </head> <body> <div id="divMessage">You have successfully updated the XML document</div> </body> </html>
Drawing ANSI/AIM Code 128 In None
Using Barcode encoder for Font Control to generate, create ANSI/AIM Code 128 image in Font applications.
www.OnBarcode.com
Painting Barcode In None
Using Barcode creator for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
CHAPTER 11 INTRODUCTION TO SERVER-SIDE XML
Quick Response Code Drawer In None
Using Barcode creator for Font Control to generate, create QR Code JIS X 0510 image in Font applications.
www.OnBarcode.com
Universal Product Code Version A Creator In None
Using Barcode maker for Font Control to generate, create GS1 - 12 image in Font applications.
www.OnBarcode.com
The code starts by collecting the values posted from the form and storing them in variables: < php $id = $_POST['txtID']; $title = $_POST['txtTitle']; $format = $_POST['txtFormat']; $genre = $_POST['txtGenre']; Again, the code creates a new DomDocument and loads the dvd.xml document: $dom = new DomDocument(); $dom->load("dvd.xml"); The code uses the same approach as on the previous page, using a domxpath object to find the selected <DVD> element: $path = "/library/DVD[@id=" . $id . "]"; $xPath = new domxpath($dom); $selectedNode = $xPath->query($path)->item(0); The code loops through the child nodes of the <DVD> element and applies the updates: foreach ($selectedNode->childNodes as $child) { if ($child->nodeName == "title") { $child ->firstChild->nodeValue = $title; } elseif ($child->nodeName == "format") { $child->firstChild->nodeValue = $format; } elseif ($child->nodeName == "genre") { $child->firstChild->nodeValue = $genre; } } Notice that the code assigns the value to the nodeValue property of the firstChild of the selected element. It s important to do this because the text within an element is the firstChild of that element. Finally, the code saves the changes: $dom->save("dvd.xml"); >
Print Data Matrix In None
Using Barcode generator for Font Control to generate, create Data Matrix 2d barcode image in Font applications.
www.OnBarcode.com
Ames Code Maker In None
Using Barcode generator for Font Control to generate, create Codabar image in Font applications.
www.OnBarcode.com
CHAPTER 11 INTRODUCTION TO SERVER-SIDE XML
Data Matrix Creation In None
Using Barcode maker for Word Control to generate, create DataMatrix image in Office Word applications.
www.OnBarcode.com
ECC200 Scanner In .NET Framework
Using Barcode scanner for .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Deleting a DVD
Barcode Recognizer In C#
Using Barcode recognizer for .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
USS Code 128 Generation In Java
Using Barcode encoder for Java Control to generate, create Code-128 image in Java applications.
www.OnBarcode.com
The last task for the application is removing a DVD from the library. The application passes the id of the element that will be removed to either the deleteDVD.aspx or deleteDVD.php page.
Printing Data Matrix ECC200 In Objective-C
Using Barcode creation for iPhone Control to generate, create Data Matrix ECC200 image in iPhone applications.
www.OnBarcode.com
Paint Code 128 In None
Using Barcode drawer for Software Control to generate, create Code128 image in Software applications.
www.OnBarcode.com
.NET: Deleting a DVD
Print Code 39 Extended In C#
Using Barcode creation for Visual Studio .NET Control to generate, create Code 39 image in Visual Studio .NET applications.
www.OnBarcode.com
EAN-13 Decoder In VB.NET
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
The deleteDVD.aspx page follows: <%@ Page Language="VB" %> <%@ import Namespace="System.Xml" %> <script runat="server"> Dim intDVDID as integer Dim myXmlDocument as XmlDocument = new XmlDocument() Dim rootNode as XMLElement Dim selectedDVD as XMLElement Sub Page_Load(Src As Object, E As EventArgs) intDVDID = request.querystring("id") myXmlDocument.Load (server.mappath("dvd.xml")) rootNode = myXmlDocument.DocumentElement selectedDVD = rootNode.childNodes(intDVDID-1) if Not Page.IsPostBack then rootNode.RemoveChild(selectedDVD) myXmlDocument.Save(Server.Mappath("dvd.xml")) lblMessage.text = "You have successfully deleted the DVD" end if end sub </script> <html> <head> <link href="styles.css" type="text/css" rel="stylesheet" /> </head> <body> <h1>Delete DVD</h1> <form runat="server"> <asp:Label id="lblMessage" runat="server" forecolor="Blue"></asp:Label> </form> </body> </html> This page is very simple. It starts with some declarations and variable definitions: <%@ Page Language="VB" %> <%@ import Namespace="System.Xml" %> <script runat="server"> Dim intDVDID as integer Dim myXmlDocument as XmlDocument = new XmlDocument() Dim rootNode as XMLElement Dim selectedDVD as XMLElement
Barcode Generation In None
Using Barcode generator for Word Control to generate, create Barcode image in Microsoft Word applications.
www.OnBarcode.com
Generating Matrix 2D Barcode In .NET Framework
Using Barcode encoder for ASP.NET Control to generate, create 2D Barcode image in ASP.NET applications.
www.OnBarcode.com
CHAPTER 11 INTRODUCTION TO SERVER-SIDE XML
Decoding Code 128 Code Set B In VS .NET
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Code39 Recognizer In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
When the page loads, it determines the id of the DVD to delete and loads the XML document: Sub Page_Load(Src As Object, E As EventArgs) intDVDID = request.querystring("id") myXmlDocument.Load (server.mappath("dvd.xml")) The code sets a variable for the document element and identifies the <DVD> element to delete: rootNode = myXmlDocument.DocumentElement selectedDVD = rootNode.childNodes(intDVDID-1) It then removes the element, saves the dvd.xml document, and displays a success message: if Not Page.IsPostBack then rootNode.RemoveChild(selectedDVD) myXmlDocument.Save(Server.Mappath("dvd.xml")) lblMessage.text = "You have successfully deleted the DVD" end if end sub </script>
PHP: Deleting a DVD from the List
The deleteDVD.php page is also very simple: < php $id = $_REQUEST['id']; $dom = new DomDocument(); $dom->load("dvd.xml"); $root = $dom->documentElement; $path = "/library/DVD[@id=" . $id . "]"; $xPath = new domxpath($dom); $DVDelement = $xPath->query($path)->item(0); $root -> removeChild($DVDelement); $dom->save("dvd.xml"); > <html> <head> <link href="styles.css" type="text/css" rel="stylesheet" /> </head> <body> <div id="divMessage">You have successfully updated the XML document</div> </body> </html>
Copyright © OnBarcode.com . All rights reserved.