|
If you find a node you want to remove, then you need to do theNode.ParentNode.RemoveChild(theNode). Something like that, the syntax is not exactly right.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
plase suggest me more, I don't understand
I can remove node <control_sub_group> by using command below
Dim listname As String
If rdo_type1.Checked Then
listname = "audit_list.xml"
ElseIf rdo_type2.Checked Then
listname = "audit_list_application.xml"
End If
'==============
Dim objdomdocument, objxmldomnode, objelement, strxpath, objCurrNode
objdomdocument = CreateObject("Microsoft.XMLDOM")
objdomdocument.async = False
objdomdocument.load(Server.MapPath(listname))
objCurrNode = objdomdocument.documentelement.firstchild
strxpath = "audit_list/control_type/control_group[@group = '" + lst_group.SelectedItem.Text.ToString() + "']/control_sub_group[@sub_group = '" + lst_subgroup.SelectedItem.Text.ToString() + "']"
objelement = objdomdocument.selectSingleNode(strxpath)
Dim i As Integer
Dim t_attribute As String
For i = 1 To 50
t_attribute = objCurrNode.childnodes(i).getattribute("group")
If t_attribute = lst_group.SelectedItem.Text.ToString() Then
objCurrNode.childnodes(i).removechild(objelement)
Exit For
End If
Next
objdomdocument.save(Server.MapPath(listname))
I think command strxpath = ....... it can get me a node <control_sub_group>
but now I want to delete node <activity> that use <control_activity> to be condition
I'm not sure if I want to delete node <activity> I can use strxpath or not/
or I should use another command?
please revise my syntax or suggest me more
thank you
|
|
|
|
|
Ah.. maybe you need to remove the inner child nodes before you can remove a node that has children of it's own ?
I was saying that if you use an XPath to find the actual node you want to remove, you can remove a node using itself as the point of reference, because there is a ParentNode property you can use to get the node one higher than the one you're at. That way, you don't have to search for nodes based on the node you want to remove being a child, but just search for the node you want.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
command ---
strxpath = "audit_list/control_type/control_group[@group = '" + lst_group.SelectedItem.Text.ToString() + "']/control_sub_group[@sub_group = '" + lst_subgroup.SelectedItem.Text.ToString() + "']"
objelement = objdomdocument.selectSingleNode(strxpath)
command above I can use parentchild.removechild(objelement) but
command ---
strxpath = "audit_list/control_type/control_group[@group = '" + lst_group.SelectedItem.Text.ToString() + "']/control_sub_group[@sub_group = '" + lst_subgroup.SelectedItem.Text.ToString() + "']/activity/control_activity"
this command not specific activity that I want to delete the activity node that i want to delete it depend on control_activity.value
this command how can i specific node activity that have node <control_activity> xxxx </control_activity>
I'm not sure do you understand my problem,I'm sorry if I make you confuse
Thank you.
|
|
|
|
|
I admit that I am unlikely to read carefully the huge amount of code you posted. If you're wanting to remove based on the parent node, then you don't need what I suggested.
Perhaps if you explained what error you are getting, it would be easier to help you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
error message is
" Object variable or with block variable not set "
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vamsgobjnotset.asp[^]
On to your code:
For j = 1 To 50
Why 50 ? Are VB arrays 1 based ? ( Nothing would surprise me ). This will give you an error if you have less than 50 elements, and not search them all if you have more
x_nodelist = objCurrNode.childnodes(j).getelementsbytagname("control_activity")
For a = 0 To x_nodelist.length
x_text = x_nodelist.item(a).firstchild.nodevalue
If you look at your schema, control_activity does not have any child nodes, which is why this blows up, with the error you describe.
If x_text = lst_activity.SelectedItem.Text.ToString() Then
objCurrNode.childnodes(j).childnodes.item(a).removechild(objelement)
and therefore, it won't even get this far.
Exit For
End If
Next
Next
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thank you very much for your kindness, but I still can't solve my problem
|
|
|
|
|
Hi - I was just looking at your x-path - -
audit_list/control_type/control_group[@group = '" + lst_group.SelectedItem.Text.ToString() + "']/control_sub_group[@sub_group = '" + lst_subgroup.SelectedItem.Text.ToString() + "']/control_activity/activity
1) I notice that: you have "activity" as child of "control-activity" while your xml is the other way around: "control-activity" is the child of "activity".
2) if this is corrected - then to remove the activity node:
Something like this:
//first get all the nodes that have control-activity = to user input
dim contActNodes, contActNode, actNode
contActNodes=objdomdocument.selectNodes("//control-activity[.='user-input']")
for each contActNode in contActNodes
//parent node of control-activity is activity
actNode = contActNode.ParentNode
//to remove activity, you need to get to the parent of activity
actNode.PerentNode.RemoveChild(actNode)
next
|
|
|
|
|
I have a XML file eg
<Root>
<Data>SomeData</Data>
<Data>More ...<Data>
</Root>
I now need to add another Data Item , I'm using XmlTextWriter.
How can I open the file without parsing the XML and add another Data item ?
and avoid having multiple root items.
Im using Windows CE so XMLDoc is too expensive, and I would like to avoid seeking through the stream to find </Root>
Thanks
.n<strike>u</strike>etter
|
|
|
|
|
|
Thanks, thought of using a seperate file, thats what I will do, but its ugly.
.nuetter
|
|
|
|
|
Is there a SAX implimentation on CE ? SAX is a model for passing through large documetns without loading them into memory.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
Is there a SAX implimentation on CE ?
Quick look at MSDN shows that there is SAX on CE.
Christian Graus wrote:
SAX is a model for passing through large documetns without loading them into memory.
So does XmlReader /XmlWriter .
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
dnh wrote:
So does XmlReader/XmlWriter.
Does it ? That's the best solution then, I would have thought.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I am a bit confused. I believe XmlReader is very fast if you want to "pull" elements/nodes etc out of the file and do something with it as this is forward-read-only stream. But according to the original question, how do you "add" a node in such a scenario?
Never mind - I looked at the article: Efficient Techniques for Modifying Large XML Files.
One other way to go would be using XPathDocument - There is a nice sample here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxml/html/sysxmlVS05.asp
|
|
|
|
|
hi,
i am having word data of whis is list style type having bullet, numbering and symbol formatting in different hierarchy.how could i capture that from word ml.
in wordml every data information is treated and present in <w:p>
wht is the soln to this.
RAM waiting for reply.
|
|
|
|
|
I have a chatting software in ASP and XML but my system is not configured to run it because The code is using DOM component object programming and i have to install this component to run it.I want to know from where i can install this component.
waiting...
EsHbAn BaHaDuR
|
|
|
|
|
It comes with the latest version of IE.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Well I have IE 6 version which is i think latest version of IE upto now.But it doesnot works.If u think that u have latest version of IE then i would send it to u to check that is it working properly.
waiting for ur courtesy.
EsHbAn BaHaDuR
|
|
|
|
|
u actaully need to download MSXML v4.0 SP2 from the Microsoft website or just google around for MSXML v4.0 SP2 and ur done with it.
Your dom application should work fine.
Regards
Wilbur J. Pereira
http://groups-beta.google.com/group/DotNetStarters
"If they love me let them, for the heck of it.If they don't, who da heck cares about it"
|
|
|
|
|
hi
This code is working fine given below
private void button31_Click(object sender, System.EventArgs e)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load("c:/farm-config.xml");
XmlElement databaseElement = xmldoc.CreateElement("database1000");
xmldoc.DocumentElement["farm-config"].PrependChild(databaseElement);
FileStream fsxml = new FileStream("c:/farm-config.xml",FileMode.Truncate,FileAccess.Write,FileShare.ReadWrite);
// XML Document Saved
xmldoc.Save(fsxml);
fsxml.Close();
}
Above code enters <database1000 /> into ram.xml file after farm-config element
I want to enter after farm name=dev1
I get error in this line given below
xmldoc.DocumentElement["//farm[@name='dev1']"].PrependChild(databaseElement);
Rest of the code is same as given above code
my xml file stiructure is given below
-----------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<root>
<farm-config>
<farm name="dev1">
<connection address="192.168.1.13" user="root" selectedConnection="1" password="">
<lastJob>Copy-All</lastJob>
<lastConnection startdate="2005-05-10" starttime="12:43:23" enddate="2005-05-10" endtime="12:58:32" />
<state>1</state>
</connection>
//here i wantto insert database element
</farm>
</farm-config>
<root>
regards
sanjeev
|
|
|
|
|
This is my xslt file
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:asp="http://schemas.microsoft.com/intellisense/ie5"
xmlns:state="http://www.vbxml.com/state"
xmlns:str="http://www.vbxml.com/string"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
</msxsl:script>
<xsl:param name="calories">1500</xsl:param>
<xsl:template match="/">
<HTML>
<BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:10pt;
background-color:#EEEEEE">
</BODY>
</HTML>
<table align="center" width="100%" border = "1">
<tr>
<td width="30%" align= "center" bordercolor="#3366ff" bgcolor="#ccccff">activity</td>
<td width="20%" align= "center" bordercolor="#3366ff" bgcolor="#ccccff">score</td>
<td width="50%" align= "center" bordercolor="#3366ff" bgcolor="#ccccff">comment</td>
</tr>
<xsl:for-each select="//form_name[@name=$calories]//*">
<tr style="FONT-SIZE: 16px; Z-INDEX: 103;COLOR: blue; FONT-FAMILY: Arial;FONT-WEIGHT: bold ">
<td colspan = "3" bordercolor="#3366ff" bgcolor="#ccccff"><xsl:value-of select="@sub_group"/></td>
</tr>
<tr style="LIST-STYLE-POSITION: outside; BORDER-BOTTOM-COLOR: #999999; LIST-STYLE-TYPE: disc; BORDER-BOTTOM-STYLE: groove" >
<td style="FONT-SIZE: 14px; Z-INDEX: 103;COLOR: blue; FONT-FAMILY: Arial"><xsl:apply-templates/></td>
<xsl:if test = "name() = 'activity'">
<td align="center"><input type = "textbox" id = "score" Width="500px"></input></td>
<td><textarea id = "comment" size = "20"/></td>
</xsl:if>
</tr>
</xsl:for-each>
</table>
<button id = "btn_score">summary score</button>
</xsl:template>
<xsl:template match="activity">
<xsl:value-of select="activity"/>
</xsl:template>
</xsl:stylesheet>
QUESTION
I add textbox (id = "score) for user and add button (id = "sum_score") I want to get data in all textbox to calculate the summary of score and calculate percent when the user click button (id = "btn_score")
can someone have a suggestion for me, please
thank you
|
|
|
|
|
You need to add an onclick to the button, which calls a javascript function that you'll also need to insert into your XSLT.
You mentioned you're using ASP.NET. You're not really, if you are, then this is all a real waste of time, unless you have a specific reason to want to avoid posting back in this instance.
By the way, it's possible to respond on the same thread, and it's also possible to edit and delete your posts.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Sorry, I'm not well to write english, may be it make a mistake about the communication
I'll try again
I mentioned using asp.net , that right, I use asp.net to make a user interface and send data form page to be a condition send to xslt file to retrieve data from xml file
and I add textbox to receive score form user and add textarea to receive comment from user
and the last when user click button I want to show summary of score
You suggest me to add javascript to xslt, I never use javascript and I think my computer not support , can I use vbscript?
Could you tell me an example or website that can solve my problem, please
Thank you so much
|
|
|
|