Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programação com XML e XSLT. 1 Web Control XML – System.Web.UI.WebControls.XML Use the Xml control to display the contents of an XML document without formatting.

Similar presentations


Presentation on theme: "Programação com XML e XSLT. 1 Web Control XML – System.Web.UI.WebControls.XML Use the Xml control to display the contents of an XML document without formatting."— Presentation transcript:

1 Programação com XML e XSLT

2 1 Web Control XML – System.Web.UI.WebControls.XML Use the Xml control to display the contents of an XML document without formatting or using XSL Transformations. PropertyDescription Document Sets the XML document using a System.Xml.XmlDocument object. DocumentContent Sets the XML document using a string. DocumentSource Sets the XML document using a file. TransformFormats the XML document using the specified System.Xml.Xsl.XslTransform object. System.Xml.Xsl.XslTransform TransformSourceFormats the XML document using the specified XSL Transformation style sheet file.

3 2 XmlDocument – XslTransform Transformação de um documento XML Display num Web XML control XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("people.xml")); XslTransform trans = new XslTransform(); trans.Load(Server.MapPath("peopletable.xsl")); xml1.Document = doc; xml1.Transform = trans; Exemplo

4 3 Preencher DataSet com XML Método ReadXml XmlTextReader string pathname=Server.MapPath("produtos.xml"); XmlTextReader tr=new XmlTextReader(pathname); mydataset=new DataSet(); mydataset.ReadXml(tr); DataGrid1.DataSource=mydataset; DataGrid1.DataBind();

5 4 Process XML Data In-Memory Discusses the two models for processing XML data. The XmlDocument class, and its associated classes, is based on the W3C Document Object Model. The XPathDocument class is based on the XPath data model.XmlDocument XPathDocument us/library/2bcctyt8.aspx us/library/2bcctyt8.aspx us/library/534aacaa.aspx

6 5 Migrating from Version 1.1 of the XML Classes us/library/534aacaa.aspx

7 6 The XslCompiledTransform class is the new XSLT processor. It replaces the XslTransform class. The XsltSettings enumeration is used to enable optional XSLT settings such as support for embedded scripts or the XSLT document() function.XslCompiledTransform XslTransformXsltSettings Version 1.1

8 7 Criar XML com informação de um DataSet (1) Método WriteXml oleDbDataAdapter1.Fill(dataset); string name=tbName.Text; string path=Server.MapPath("."); string filepath=path+"\\ " + name; dataset.WriteXml(filepath); Vários overload: DataSet.WriteXml (String) DataSet.WriteXml (XmlWriter, XmlWriteMode) …

9 8 Criar XML com informação de um DataSet (2) Método GetXml do DataSet Class XPathNavigator Provides a cursor model for navigating and editing XML data. Class XPathDocument Provides a fast, read-only, in-memory representation of an XML document using the XPath data model. string strxml = dataset.GetXml(); StringReader str=new StringReader(strxml); XPathDocument docpath = new XPathDocument(str); XPathNavigator nav=docpath.CreateNavigator(); Xml1.XPathNavigator = nav; Xml1.DataBind();

10 9 Actualizar BD com documento XML – (tabela Produtos) string pathname2= Server.MapPath("produtos2.xml"); DataSet novo=new DataSet(); novo.ReadXml(pathname2); oleDbDataAdapter1.Update(novo,"Produtos");

11 10 Transformações XSLT Class XslCompileTransform Microsoft.NET Framework XSLT processor. This class is used to compile style sheets and execute XSLT transformations.


Download ppt "Programação com XML e XSLT. 1 Web Control XML – System.Web.UI.WebControls.XML Use the Xml control to display the contents of an XML document without formatting."

Similar presentations


Ads by Google