|
I have the following xml:
<configuration>
<configObj>
<name>aaa</name>
<value>1234</value>
</configObj>
<configObj>
<name>bbb</name>
<value>5678</value>
</configObj>
</configuration>
I know the expression to get all the values, but I need to get for example the value for name aaa, is there an Expression string to do this?
Thanks in advance!
Cristina
|
|
|
|
|
This should do the job:
/configuration/configObj[name='aaa']/value
Select the correct configObj with the predicate name='aaa' , then select the child element you want.
HTH.
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
I have a problem about my Project.I want to ask about that.I am trying to build an application that you can transform a xml document into another xml document with drag-drop elements of the source xml document into the elements of the target xml document.Stylus Studio Editor has this kind of property called XSLT Mapper.When you drag an element into target element xsl source code is created below side of the window.I want to develop this kind of application.
But I could not have found what i should do.Could you help about this application?How should I develop this program and which properties of .NET I should use?
Thanks for a lot...
|
|
|
|
|
can marquee tag used in html can also be used in WML? or in XML??? or any other tags can be used for instead????
|
|
|
|
|
The Marquee tag can be used in XML, however, it does not scroll the contents like the marquee tag in HTML. Remember that XML only holds data, it is up to the application to determine how to read/display it.
--
Aaron Eldreth
|
|
|
|
|
I am using DOM parser to read an XML file but i am unable to read the XML file when it is in indented form.
Using the javax.xml.transform.Transformer i can write the XML file in indented form but can't read it in indented form.please tell me where i m lacking.
sangi2007
|
|
|
|
|
Hi
Can anyone tell me
HOW CAN I SAVE A PICTURE FILE OR PICTUREBOX.IMAGE IN XML FILE IN VB.NET?
i must save my form and all it's component in XML format and then again create my form by using my xml file. how can i do this and save image in picturebox on my form?
Best Regards
M.Khayatan
MkhProgrammer
|
|
|
|
|
Save it as a base64 encoded string.
Ryan
Ryan.
It's yet another shock to our system to discover that not only are we not the centre of the Universe and we're not made of anything, but we started out as some kind of slime and got to where we are via being a monkey. It just doesn't read well.
Douglas Adams
|
|
|
|
|
Hi,
that is nasty. IMHO you should only refer to picture file in XML instead of inserting binary file into XML, since it is text format.
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Hello,
I am trying to read a XML file which has japanese characters -- The XMPL processor I am using is LIBXML2.
The XML file I am trying to read is as follows:
<><<response result="failure" loglevel="5" cname="recognizeversion" csever="10.5" addn="abc" focusbrowser="true" iid="1480" cse="SolidWorks" ver="10.5">><<info>><<reason>>ãƒãƒ¼ã‚¸ãƒ§ãƒ³èªè˜ã¯ãƒ¦ãƒ¼ã‚¶ã«ã‚ˆã£ã¦ãƒãƒ£ãƒ³ã‚»ãƒ«ã•ã‚Œã¾ã—ãŸ<><><>
Note, that the junk characters above are the japanese characters. If I save this file and open in IE then the characters are displayed in Japanese.
I using the following code to read the japanese character as contained in the <response>.<info>.<reason> section.
xmlChar * xmlStr = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
CString xx = xmlStr;
AfxMessageBox(xx);
The above messagebox shows junk characters. I want it to display it as is visible in the IE.
Where am I doing the things wrong.
Thanks in advance.
Regards,
Amol
|
|
|
|
|
- Are you using a Unicode build? If not, CString will interpret xmlStr as ASCII characters, resulting in what you've got there.
- Even if you've got a Unicode build...you're not telling anything that xmlStr is UTF-8...
You can verify that libxml is reading the characters correctly by using xmllint (it converts the Japanese characters to numeric entities) and looking up the character codes in charmap.
In order to convert the UTF-8 that libxml gives you to (say) UTF-16, you can use code like this:
<br />
const int WIDE_COUNT = 1024;<br />
wchar_t wide[WIDE_COUNT] = {0};<br />
int inLen = lstrlenA(LPCSTR(xmlStr));<br />
int outLen = WIDE_COUNT;<br />
xmlCharEncodingHandlerPtr handler = xmlGetCharEncodingHandler(XML_CHAR_ENCODING_UTF16LE);<br />
int nOut = handler->output((xmlChar*)wide, &outLen, xmlStr, &inLen);<br />
This puts the same UTF-16 values in the string wide that xmllint displays as numerical entities.
As to displaying the characters in a message box - I'm afraid I don't know - it'll be character sets again, or fonts, though!!!
HTH
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Can somebody help me on the article http://www.codeproject.com/miscctrl/cntGroup.asp.
Sample?
Regards,
Rainer
|
|
|
|
|
Hie...
I have a login page using XML to store my UserEmail and UserPass.
Now, I want to verify with the XML, if user type a correct UserEmail and UserPass, then login proceed; if not, message text: This is an invalid Account.
Please help?
Thanks.
|
|
|
|
|
This is my first .Net application so i appologise for my stupidity. What the application is, is a navigation control for an intranet that a colleage has been building. It uses a .Net component (ASP.NET DHTML Menu)
http://www.apnsoft.com/?L=E&LM=Menu_Main&MD=Menu_Features
which uses strong xml.
My task has been to create an app to edit this xml in .NET. So i have set about learning all i can about how (the #uck) to do this ... here is a little drawing of what i have come up with:
www.elevatordigital.com/images/myplan.gif
My question is is it possible to take the stream created with the SqlCommandClass directly to the xml file main.xml?
Any help with this would be greatly appreciated. Im slightly out of my depth with this project so if anyone thinks there is a better way of achieving this i would love to hear about it.
Cheers
Kate
|
|
|
|
|
I have created a datagrid to edit the SQL database and a page which has the following code onLoad:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Load proper XML from SQL Server
Dim strConn As String = "My Connection String is Here"
' Define the XML command
Dim cmd As SqlXmlCommand = New SqlXmlCommand(strConn)
' Set up a SqlXmlCommand from a xml template using FOR XML EXPLICIT
cmd.CommandType = SqlXmlCommandType.Template
cmd.CommandText = Server.MapPath(@"template.xml");
cmd.BasePath = Server.MapPath(@"\");
' Specify a root element for the result
cmd.RootTag = "menu"
' Read the XML into an XmlReader
Dim xr As XmlReader = _
cmd.ExecuteXmlReader()
' Transfer it to an XmlDOcument
Dim xd As XmlDocument = New XmlDocument
xd.Load(xr)
xr.Close()
' Get a Transform ready
Dim xslt As XslTransform = New XslTransform
xslt.Load("main.xslt")
' Use the transform to rewrite it
Dim ms As MemoryStream = New MemoryStream
xslt.Transform(xd, Nothing, ms)
Dim mywriter As System.Xml.XmlTextWriter
mywriter = New System.Xml.XmlTextWriter("main.xml", Nothing)
With mywriter
.WriteStartDocument()
.WriteString(ms)
.WriteEndElement()
.WriteEndDocument()
End With
mywriter.Flush()
mywriter.Close()
End Sub
But i have got syntax errors at these elements:
1. cmd.CommandText = Server.MapPath(@"template.xml");
2. cmd.BasePath = Server.MapPath(@"\");
3. xslt.Transform(xd, Nothing, ms) - I think this is to do with the memory stream
4. .WriteString(ms) - I think i need to convert the memory steam to a string using Streamreader
If anyone can help me with these problem that would be a grea help
Cheers
Kate
|
|
|
|
|
hi,
yeah I know, too late for help. And i am not even really helpful...
a) since I hate coding in this *pseudocode* (I mean VB) no way how to help with syntax errors
b) why not to try language begining with "C"?
c) how is menu stored in DB? adding separators using xslt sounds little strange to me...
d) IMO there is no way how to directly store sql query result into xml file, since XmlReader is for reading, not for writing. You may want to create e.g XmlDocument and then save it with XmlDocument.Save() to file. You can even insert <separator> tags with XmlDocument.InsertAfter() method. Look for more at msdn.com.
e) I am quite tired so in case I am writing bulls*it, sry.
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Hi,
Ive actually solved the problem now - I ended up creating Custom Classes for the two database tables and writing out the xml using asp.net:
Imports System.Xml
Imports NWDAweb.Classes.newsStories
Public Class PlasmaThanks
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents XMLTextBox As System.Web.UI.WebControls.TextBox
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim newsStoryObjList As newsStoryObjList = New newsStoryObjList
Dim xmlDoc As XmlDocument = New XmlDocument
Dim menuElement As XmlElement = xmlDoc.CreateElement("menu")
xmlDoc.AppendChild(menuElement)
If newsStoryObjList.SelectAll("plasmaScreen = 1", "datePosted") Then
For Each newsStoryObj As newsStoryObj In newsStoryObjList
Dim storyElement As XmlElement = xmlDoc.CreateElement("story")
Dim titleElement As XmlElement = xmlDoc.CreateElement("title")
Dim bodyElement As XmlElement = xmlDoc.CreateElement("body")
titleElement.InnerText = Server.HtmlEncode(newsStoryObj.headline)
bodyElement.InnerText = StripHTML(Server.HtmlDecode(newsStoryObj.bodyCopy))
storyElement.AppendChild(titleElement)
storyElement.AppendChild(bodyElement)
menuElement.AppendChild(storyElement)
Next
XMLTextBox.Text = xmlDoc.InnerXml
XMLTextBox.Visible = False
Dim xmlStreamWriter As System.IO.StreamWriter = System.IO.File.CreateText(Server.MapPath("news.xml"))
Try
xmlStreamWriter.Write(xmlDoc.InnerXml.Replace("&", "&").Replace(vbCrLf & vbCrLf, vbCrLf))
xmlStreamWriter.Close()
Catch
End Try
End If
End Sub
Private Function StripHTML(ByVal strIn As String) As String
Dim pattern As String = "<[^>]*>"
Return System.Text.RegularExpressions.Regex.Replace(strIn, pattern, String.Empty)
End Function
End Class
But thanks for the response
|
|
|
|
|
Hi,
Ive actually solved the problem now - I ended up creating Custom Classes for the two database tables and writing out the xml using asp.net:
Imports System.Xml
Imports NWDAweb.Classes.newsStories
Public Class PlasmaThanks
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents XMLTextBox As System.Web.UI.WebControls.TextBox
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim newsStoryObjList As newsStoryObjList = New newsStoryObjList
Dim xmlDoc As XmlDocument = New XmlDocument
Dim menuElement As XmlElement = xmlDoc.CreateElement("menu")
xmlDoc.AppendChild(menuElement)
If newsStoryObjList.SelectAll("plasmaScreen = 1", "datePosted") Then
For Each newsStoryObj As newsStoryObj In newsStoryObjList
Dim storyElement As XmlElement = xmlDoc.CreateElement("story")
Dim titleElement As XmlElement = xmlDoc.CreateElement("title")
Dim bodyElement As XmlElement = xmlDoc.CreateElement("body")
titleElement.InnerText = Server.HtmlEncode(newsStoryObj.headline)
bodyElement.InnerText = StripHTML(Server.HtmlDecode(newsStoryObj.bodyCopy))
storyElement.AppendChild(titleElement)
storyElement.AppendChild(bodyElement)
menuElement.AppendChild(storyElement)
Next
XMLTextBox.Text = xmlDoc.InnerXml
XMLTextBox.Visible = False
Dim xmlStreamWriter As System.IO.StreamWriter = System.IO.File.CreateText(Server.MapPath("news.xml"))
Try
xmlStreamWriter.Write(xmlDoc.InnerXml.Replace("&", "&").Replace(vbCrLf & vbCrLf, vbCrLf))
xmlStreamWriter.Close()
Catch
End Try
End If
End Sub
Private Function StripHTML(ByVal strIn As String) As String
Dim pattern As String = "<[^>]*>"
Return System.Text.RegularExpressions.Regex.Replace(strIn, pattern, String.Empty)
End Function
End Class
But thanks for the response
|
|
|
|
|
Hie,
All I want to display what is on the XML put on the datagrid at the same time, want a delete hyperlink to delete my user.
How to do it?
The Edit or Add function can ignore it or the best is delete it.
Let's look at the coding.
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Page Language="VB" Inherits="System.Web.UI.Page" %>
<title>Delete User Account
dim gXmlfile as string = "~/data/Users.xml"
dim gXmlPath as string
' =================================
Sub Page_Load(Src As Object, E As EventArgs)
gxmlpath = server.mappath( gXmlfile ) 'file is in same folder as page
If Not (IsPostBack)
DataLoad("UserEmail")
End If
End Sub
' ========================================
Sub DataLoad(parmsort as string)
Dim ds As New DataSet
Dim FS As New FileStream(Server.MapPath(gXmlFile), FileMode.Open)
ds.ReadXml(FS)
' 02/14/02 pchu handle an empty file ---------------------------
if ds.tables.count = 0 then
ds.tables.add( MakeBooksTable() )
end if
trace.warn ( "rowcount1 = " , cstr(ds.Tables(0).rows.count ))
' 02/14/02 pchu ---------------------------
' Add code to sort the dataview if parmsort is present
'ok let's get fancy and insert a blank row at the top
dim sw1 as integer = 1
select case sw1
case 1
dim dr as datarow = ds.Tables(0).newrow()
'put something in the first column ISBN
dr("UserEmail") = " Add UserEmail"
ds.Tables(0).rows.insertat(dr, 0)
trace.warn ( "rowcount2 = " , cstr(ds.Tables(0).rows.count ))
end select
'create dv and bind it to datagrid
dim dv as dataview
dv = new DataView(ds.Tables(0))
if parmsort.length > 0 then
dv.sort = parmsort
end if
MyDataGrid.DataSource = dv
'old MyDataGrid.DataSource = new DataView(ds.Tables(0))
' 02/14/02 pchu ---------------------------
MyDataGrid.DataBind()
FS.close()
END SUB
' ========================================
Sub DataSort(Src As Object, E As DataGridSortCommandEventArgs)
' Bug if we sort, then Edit Item Becomes Wrong
IF MyDataGrid.EditItemIndex=-1 THEN
DataLoad(e.sortexpression)
ELSE
response.write ("Can't sort until editing is done!")
END IF
End Sub
Sub DataDelete(Sender As Object, E As DataGridCommandEventArgs)
dim deletekey as string
If MyDataGrid.EditItemIndex=-1 Then
deletekey=MyDataGrid.DataKeys(CInt(E.Item.ItemIndex))
response.write ("Delete completed for key = " & deletekey)
Else
response.write ("Can't delete until editing is done!")
End If
'' Dim currentRow As Integer = e.Item.DataSetIndex
Dim currentRow As Integer = e.Item.itemindex
'02/16/02 BugFix: because the datagrid has an insert row which is NOT in the
' in the dataset table, we have to subtract one to compensate for the that fact
currentrow = currentrow - 1 'bug fix: subtract 1 because the grid has a insert row
trace.warn (" current row to delete ", cstr(currentrow) )
' reload the XML file into a dataset
Dim ds As New DataSet()
ds.ReadXml(Server.MapPath(gXmlFile))
' get a reference to this row of data
Dim row As DataRow = ds.Tables(0).Rows( currentrow )
row.delete() '-- kill this row in the dataset (disabled for example)
' save the updated dataset to the XML file
ds.WriteXml(Server.MapPath(gXmlFile))
mydatagrid.EditItemIndex = -1 'exit delete mode
dataload("") ' redisplay and rebind datagrid
END SUB
Sub DataEdit(Sender As Object, E As DataGridCommandEventArgs)
DIM editkey as string
trace.warn ("e.item.itemindex = ", cstr(e.item.itemindex) )
MyDataGrid.EditItemIndex = Cint(E.Item.ItemIndex )
editkey=MyDataGrid.DataKeys(CInt(E.Item.ItemIndex))
trace.warn ("page.aspx", "To Be Edited" & editkey)
SetEditMode( "on" )
DataLoad("")
End Sub
' ===================================
public sub dg_itemcreated ( sender as object, e as datagriditemeventargs )
if e.item.itemindex = 0 then 'first row
dim lbDelete as linkbutton = e.item.cells(0).controls(0)
trace.warn ("page.aspx", "lbDelete = " & lbDelete.text )
if lbDelete.text = "Delete User" then
lbDelete.text = ""
end if
end if
if e.item.itemindex > 0 then 'first row
select case e.item.itemtype
case listitemtype.item
dim mydeletebutton as tablecell
mydeletebutton = e.item.cells(0)
mydeletebutton.attributes.add("onclick", _
"return confirm('Are you sure you want to Delete?');" )
case listitemtype.alternatingitem
dim mydeletebutton as tablecell
mydeletebutton = e.item.cells(0)
mydeletebutton.attributes.add("onclick", _
"return confirm('Are you sure you want to Delete?');" )
end select
end if
end sub
' =========================
Private Function MakeUserTable() As DataTable
' Create a new DataTable titled 'Login.'
Dim theTable As DataTable = new DataTable("Login")
' Add two column objects to the table.
Dim theColumn1 As DataColumn = new DataColumn()
theColumn1.DataType = System.Type.GetType("System.String")
theColumn1.ColumnName = "UserEmail"
theTable.Columns.Add(theColumn1)
Dim theColumn2 As DataColumn = new DataColumn()
theColumn2.DataType = System.Type.GetType("System.String")
theColumn2.ColumnName = "UserPassword"
theTable.Columns.Add(theColumn2)
' Create an array for DataColumn objects.
Dim keys(0) As DataColumn
keys(0) = theColumn1
theTable.PrimaryKey = keys
' Return the new DataTable.
MakeUserTable = theTable
End Function
Delete User Account
<asp:datagrid id="MyDataGrid" style="Z-INDEX: 101; LEFT: 96px; POSITION: absolute; TOP: 56px"
="" runat="server" onitemcreated="dg_itemcreated" font-names="Verdana" headerstyle-font-size="10pt" headerstyle-backcolor="lightblue" font-size="8pt" font-name="Verdana" cellpadding="3" bordercolor="Black" backcolor="White" datakeyfield="isbn" ondeletecommand="DataDelete" allowsorting="True" width="400px" height="56px">
<headerstyle font-size="10pt" backcolor="LightBlue">
<columns>
<asp:buttoncolumn text="Delete User" commandname="mydeletebutton">
-------------------------------------------------------------------------
Users.xml file
<login>
<users>
<useremail>smurf@hotmail.com
<userpassword>CC0C3DBD8A231B92307C537673CFB26BDB24B421
<users>
<useremail>Duncan@yahoo.com
<userpassword>A9C53C9934EF3B01D0873BF3C6A9B291749A6454
<users>
<useremail>james@home.com
<userpassword>EB01D8F828A6C9A20BE4534E72E049AAF41503DF
Worried,
|
|
|
|
|
I have been working with XML for a while and quite often, I need to write navigation functions to search for a particular DOM model, such as find a book with a particular keyword but the publisher has to be somePublishName, plus the price of the book cannot be hight than $50.00, etc. The code to finish this task is somehow quite alike and tedious, I was just wondering if there is any tool to help on this part? For example, what about the TreeWalker thing with a NodeFilter? anyone heard of this and had some experience with this? Basically the searching in the XML file is very tedious and somewhat repeatable, any tools for this.
|
|
|
|
|
If u r looking for tools, u can use xmlspy.
I guess there is a free version also.
cool man
|
|
|
|
|
Hi,
I have a XML file which needs to be first validated using a DTD and then parsed to get values & properties associated with tags.
I am using Visual Studio's VC++ 6.0 to write my code. Is anyone aware of any reference or tutorial which would help me learn the same.
Thanks You!!
Regards
|
|
|
|
|
|
this is a piece of the xsl i use:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:output omit-xml-declaration="no" method="xml" indent="yes" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />
...
<input type="hidden" name="projectcode">
<xsl:attribute name="value">
<xsl:value-of select="../PROJECTCODE"/>
</xsl:attribute>
</input>
...
but when i render the xml using System.Xml.Xsl.XslTransform, the result is not valid xhtml. The hidden input is generated as:
<input type="hidden" name="projectcode" value="123"></input>
in stead of:
<input type="hidden" name="projectcode" value="123" />
does anyone have any idea what i am doing wrong??
|
|
|
|
|
Use the inline syntax for your attribute then you can have a closed tag element.
|
|
|
|