SlideShare a Scribd company logo
1 of 27
ECMAScript for XML (E4X) מגישים  : ויטלי שלמן תומר דוד סרגיי קפלן “ E4X brings simplicity, convenience, and fun to XML processing … Both of Mozilla's JavaScript engines will support E4X in the near future.” –  Brendan Eich, CTO of Mozilla.org and inventor of JavaScript
חזרה ,[object Object],[object Object],[object Object],[object Object]
הכרת חלקי מסמך ה - XML   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XML   –  הוראות תחביריות  ( כללי ) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
דוגמה   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],אנו רוצים לאחזר מתוך העץ את כל השמות הפרטיים של הסופרים המופעים בעץ .
DOM   -   Document   Object   Model   ,[object Object],[object Object],[object Object],[object Object],[object Object]
פתרון  DOM Dim c As String c = &quot;<?xml version='1.0' encoding='utf8'?><Authors><Author> <FirstName>John</FirstName><LastName>Doe</LastName> </Author><Author><FirstName>Jane</FirstName><LastName> Eod</LastName></Author></Authors>“ Dim doc As New XmlDocument doc.LoadXml(c) Dim _fnames As XmlNodeList = doc.GetElementsByTagName(&quot;FirstName&quot;) Dim my_nodes As XmlNodeList Dim my_node As XmlNode For Each my_node In _fnames TextBox1.Text = TextBox1.Text & my_node.OuterXml Next DOM!
Xpath  -  הקדמה ,[object Object],[object Object]
תחביר  xpath -  הקדמה ,[object Object],[object Object],[object Object]
סוגי סימנים מוסכמים בתחביר  xpath הסימן תאור / בחירה מרמת קישור השורש // בחירה מרמת המיקום הנוכחי בקישור . בחירת הקישור הנכחי .. בחירת קישור האב של הקישור הנוכחי @ בחירת ערך
דוגמא למשפטי  xpath ביטוי  xpath הסבר bookstore   בחר את כל הקשרים שתחת  bookstore / bookstore   בחר את האלמנט  bookstore  הנמצא תחת השורש bookstore/book  בחר את אלמנט  book   אשר הם בנים של אלמנט  bookstore //book  בחר את כל אלמנטי  book   שקיימים במסמך ללא קשר למקומם bookstore//book  בחר את כל אלמנטי  book  שהם צאצאים של  bookstore //@lang  בחר את כל הערכים מסוג  lang  בלי קשר למקומם במסמך
פתרון   xpath ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
X 4 E   הקדמה ,[object Object],[object Object],[object Object],[object Object],[object Object]
X 4 E   הקדמה  -  המשך ,[object Object],[object Object],[object Object],[object Object]
E4X יתרונות ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],מספק מודל מוכר ופשוט לתכנות של  XML   אשר :
חסרונות ,[object Object],[object Object],[object Object],נניח יש לנו עץ  XML : var myxml  =  <p><b>Hello< / b> <i>World< / i></p>   אבל אין לנו אפשרות לעשות שימוש ב - DOM : var p_element  =  document . createElement ( myxml ) My_element . appendChild ( p_element)
פתרון E4X  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
סוגי סימנים מוסכמים בתחביר  X 4 E ,[object Object]
דוגמא נוספת :
נתון עץ  : <bookstore> <book>   <title lang=&quot;eng&quot;>Harry Potter</title>   <price>29.99</price>  </book> <book>   <title lang=&quot;eng&quot;>Learning XML</title>  <price>39.95</price>  </book> </bookstore>
הוספת ענף : <bookstore> <book>   <title lang=&quot;eng&quot;>Harry Potter</title>   <price>29.99</price>  </book> <book>   <title lang=&quot;eng&quot;>Learning XML</title>  <price>39.95</price>  </book> <book> <title lang=“eng&quot;>Test Book</title>  <price>78.55</price>  </book> </bookstore>
פתרון ב  DOM Dim c As String = &quot;<?xml version='1.0' encoding='utf-8'?><bookstore><book> <title lang='eng'>Harry Potter</title><price>29.99</price></book><book> <title lang='eng'>Learning XML</title><price>39.95</price></book></bookstore>&quot; Dim xmldoc As New XmlDocument xmldoc.LoadXml(c) Image1.Visible = True Dim el0 As XmlElement = xmldoc.CreateElement(&quot;book&quot;) Dim el1 As XmlElement = xmldoc.CreateElement(&quot;title&quot;) el1.SetAttribute(&quot;lang&quot;, &quot;en&quot;) Dim el1string As XmlText = xmldoc.CreateTextNode(&quot;Test Book&quot;) el1.AppendChild(el1string) Dim el2 As XmlElement = xmldoc.CreateElement(&quot;price&quot;) Dim el2Text As XmlText = xmldoc.CreateTextNode(&quot;78.55&quot;) el2.AppendChild(el2Text) el0.AppendChild(el1) el0.AppendChild(el2) xmldoc.SelectSingleNode(&quot;/bookstore&quot;).AppendChild(el0) Textbox2.Text = xmldoc.OuterXml
פתרון ב  X 4 E var bookstore = <bookstore><book><title lang='eng'> Harry Potter</title><price>29.99</price> </book><book><title lang='eng'>Learning XML</title> <price>39.95</price></book></bookstore> bookstore.book[xml.user.length()] = <book><title lang=“eng&quot;> Test Book</title><price>78.55</price></book>
תרגיל כיתה ,[object Object],[object Object],[object Object],[object Object]
בוחן ,[object Object]
מקורות ,[object Object],[object Object],[object Object],[object Object]
[object Object]

More Related Content

Viewers also liked

5 reasons people fear Realtime Feedback Solutions
5 reasons people fear Realtime Feedback Solutions5 reasons people fear Realtime Feedback Solutions
5 reasons people fear Realtime Feedback SolutionsResourceful Humans
 
Mashudu Engineering
Mashudu EngineeringMashudu Engineering
Mashudu Engineeringkatlego
 
PHILIPPINE CONTEMPORARY POPULAR MUSIC 90s alternative music
PHILIPPINE CONTEMPORARY POPULAR MUSIC 90s alternative musicPHILIPPINE CONTEMPORARY POPULAR MUSIC 90s alternative music
PHILIPPINE CONTEMPORARY POPULAR MUSIC 90s alternative musicMony Romana
 
PHILIPPINE CONTEMPORARY POPULAR MUSIC REPORT
PHILIPPINE CONTEMPORARY POPULAR MUSIC REPORTPHILIPPINE CONTEMPORARY POPULAR MUSIC REPORT
PHILIPPINE CONTEMPORARY POPULAR MUSIC REPORTMony Romana
 

Viewers also liked (8)

5 reasons people fear Realtime Feedback Solutions
5 reasons people fear Realtime Feedback Solutions5 reasons people fear Realtime Feedback Solutions
5 reasons people fear Realtime Feedback Solutions
 
The Way of Resourceful Humans
The Way of Resourceful HumansThe Way of Resourceful Humans
The Way of Resourceful Humans
 
Usability
UsabilityUsability
Usability
 
ITV
ITVITV
ITV
 
Mashudu Engineering
Mashudu EngineeringMashudu Engineering
Mashudu Engineering
 
3G
3G3G
3G
 
PHILIPPINE CONTEMPORARY POPULAR MUSIC 90s alternative music
PHILIPPINE CONTEMPORARY POPULAR MUSIC 90s alternative musicPHILIPPINE CONTEMPORARY POPULAR MUSIC 90s alternative music
PHILIPPINE CONTEMPORARY POPULAR MUSIC 90s alternative music
 
PHILIPPINE CONTEMPORARY POPULAR MUSIC REPORT
PHILIPPINE CONTEMPORARY POPULAR MUSIC REPORTPHILIPPINE CONTEMPORARY POPULAR MUSIC REPORT
PHILIPPINE CONTEMPORARY POPULAR MUSIC REPORT
 

E4X

  • 1. ECMAScript for XML (E4X) מגישים : ויטלי שלמן תומר דוד סרגיי קפלן “ E4X brings simplicity, convenience, and fun to XML processing … Both of Mozilla's JavaScript engines will support E4X in the near future.” – Brendan Eich, CTO of Mozilla.org and inventor of JavaScript
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. פתרון DOM Dim c As String c = &quot;<?xml version='1.0' encoding='utf8'?><Authors><Author> <FirstName>John</FirstName><LastName>Doe</LastName> </Author><Author><FirstName>Jane</FirstName><LastName> Eod</LastName></Author></Authors>“ Dim doc As New XmlDocument doc.LoadXml(c) Dim _fnames As XmlNodeList = doc.GetElementsByTagName(&quot;FirstName&quot;) Dim my_nodes As XmlNodeList Dim my_node As XmlNode For Each my_node In _fnames TextBox1.Text = TextBox1.Text & my_node.OuterXml Next DOM!
  • 8.
  • 9.
  • 10. סוגי סימנים מוסכמים בתחביר xpath הסימן תאור / בחירה מרמת קישור השורש // בחירה מרמת המיקום הנוכחי בקישור . בחירת הקישור הנכחי .. בחירת קישור האב של הקישור הנוכחי @ בחירת ערך
  • 11. דוגמא למשפטי xpath ביטוי xpath הסבר bookstore בחר את כל הקשרים שתחת bookstore / bookstore בחר את האלמנט bookstore הנמצא תחת השורש bookstore/book בחר את אלמנט book אשר הם בנים של אלמנט bookstore //book בחר את כל אלמנטי book שקיימים במסמך ללא קשר למקומם bookstore//book בחר את כל אלמנטי book שהם צאצאים של bookstore //@lang בחר את כל הערכים מסוג lang בלי קשר למקומם במסמך
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 20. נתון עץ : <bookstore> <book> <title lang=&quot;eng&quot;>Harry Potter</title> <price>29.99</price> </book> <book> <title lang=&quot;eng&quot;>Learning XML</title> <price>39.95</price> </book> </bookstore>
  • 21. הוספת ענף : <bookstore> <book> <title lang=&quot;eng&quot;>Harry Potter</title> <price>29.99</price> </book> <book> <title lang=&quot;eng&quot;>Learning XML</title> <price>39.95</price> </book> <book> <title lang=“eng&quot;>Test Book</title> <price>78.55</price> </book> </bookstore>
  • 22. פתרון ב DOM Dim c As String = &quot;<?xml version='1.0' encoding='utf-8'?><bookstore><book> <title lang='eng'>Harry Potter</title><price>29.99</price></book><book> <title lang='eng'>Learning XML</title><price>39.95</price></book></bookstore>&quot; Dim xmldoc As New XmlDocument xmldoc.LoadXml(c) Image1.Visible = True Dim el0 As XmlElement = xmldoc.CreateElement(&quot;book&quot;) Dim el1 As XmlElement = xmldoc.CreateElement(&quot;title&quot;) el1.SetAttribute(&quot;lang&quot;, &quot;en&quot;) Dim el1string As XmlText = xmldoc.CreateTextNode(&quot;Test Book&quot;) el1.AppendChild(el1string) Dim el2 As XmlElement = xmldoc.CreateElement(&quot;price&quot;) Dim el2Text As XmlText = xmldoc.CreateTextNode(&quot;78.55&quot;) el2.AppendChild(el2Text) el0.AppendChild(el1) el0.AppendChild(el2) xmldoc.SelectSingleNode(&quot;/bookstore&quot;).AppendChild(el0) Textbox2.Text = xmldoc.OuterXml
  • 23. פתרון ב X 4 E var bookstore = <bookstore><book><title lang='eng'> Harry Potter</title><price>29.99</price> </book><book><title lang='eng'>Learning XML</title> <price>39.95</price></book></bookstore> bookstore.book[xml.user.length()] = <book><title lang=“eng&quot;> Test Book</title><price>78.55</price></book>
  • 24.
  • 25.
  • 26.
  • 27.