|
|
|
Hi
I've been using XMLTextReader to be able to edit elements within an XML file easily (using the lineNumber and linePosition with a simple text handler), however I'm having a problem with navigating...
The object returned by readSubTree() is not of type XMLTextReader, so I can't use that and still get the line info out of it, and there doesn't appear to be a move/readToParent function that would take me back up a level in the XML. I could use readFollowing to move to the next element on the Parent's level but that seems like a bit of a bodge.
Can someone tell me if/how I can read back to the parent element?
Basically I want to be able to find the line info for a couple of child elements of a particular group of elements (if that makes any sense whatsoever )
|
|
|
|
|
XmlTextReader is forward only reader. You cannot read the values already read.
So what you can do is use a variable to store the parent.
Here is an example. I have not modified the code(just copy/paste)
while (xmlTextReader.Read())
{
switch (xmlTextReader.NodeType)
{
case XmlNodeType.Element:
string elementName = xmlTextReader.Name;
EntityBase entityBase = EntityHelper.CreateEntity(elementName);
while (xmlTextReader.MoveToNextAttribute())
{
if ( xmlTextReader.Name == "ID" )
{
entityBase.ValueList["ID"] = xmlTextReader.Value;
}
else if ( xmlTextReader.Name == "Name" )
{
TreeNode tempTreeNode = new TreeNode( xmlTextReader.Value.Trim());
entityBase.ValueList["Name"] = xmlTextReader.Value;
tempTreeNode.ImageIndex = ENTITYIMAGE;
if ( currentTreeNode == null )
{
tempTreeNode.Tag = entityBase;
currentTreeNode = tempTreeNode;
this.Nodes.Add(tempTreeNode);
}
else
{
tempTreeNode.Tag = entityBase;
currentTreeNode.Nodes.Add(tempTreeNode);
currentTreeNode = tempTreeNode;
}
//
//Add the dummy node
//
this.dummyNode = new TreeNode("dummy");
tempTreeNode.Nodes.Add(this.dummyNode);
break;
}
else
{
entityBase.ValueList[xmlTextReader.Name] = xmlTextReader.Value;
}
}
break;
case XmlNodeType.Text:
Console.Write(xmlTextReader.Value);
break;
case XmlNodeType.CDATA:
Console.Write(xmlTextReader.Value);
break;
case XmlNodeType.ProcessingInstruction:
Console.Write("");
break;
case XmlNodeType.Comment:
Console.Write("");
break;
case XmlNodeType.Document:
Console.Write("");
break;
case XmlNodeType.Whitespace:
Console.Write(xmlTextReader.Value);
break;
case XmlNodeType.SignificantWhitespace:
Console.Write(xmlTextReader.Value);
break;
case XmlNodeType.EndElement:
if ( currentTreeNode != null )
{
if ( currentTreeNode.Parent == null )
{
currentTreeNode = null;
}
else
{
currentTreeNode = currentTreeNode.Parent;
}
}
break;
}
}
xmlTextReader.Close();
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hello, I bind datas in the datagrid from the database in that grid 3 columns. 1. Username, 2. Password and final Template column(in that column used checkbox control) and one button in the web form the button caption 'DELETE' when i press the delete button i want to delete Username and password Wheather it is checked by the Template column(checkbox column).
Pls help me to validate the template column (CheckBox column i want to check it select or not)
|
|
|
|
|
Please post this in ASP.NET forum.
Live Life King Size
Alomgir Miah
|
|
|
|
|
Can any one help me out? I want a solution for how to zip and unzip files or folders using c#.
Thanx in advance
|
|
|
|
|
This is new in C# 2.0.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
|
Hi!
I have a datagrid with some custom DataGridComboBoxColumns. I have 3 columns that are supposed to be filled with different data according to what is chosen i the other comboboxes. It's kinda like this. 1st column is e.g. a list of box names. The 2nd column are item types inside a selected box. 3rd column contains names of the selected item type. If you have 2 items of type 'Car' in the box, the 3rd column will contain e.g. "Car 1", "Car 2".
I set the datasource for the comboboxes in a TableStyle. I need the data for each combobox to be updated dynamically and i need different values in the comboboxes for each row.
Is this even possible??
Thanks,
Atle
|
|
|
|
|
I have problem about WebBrowser.
When program open webpage http://racing.ustrotting.com/entries.cfm and click button view already.
It's not save webpage after click button view but it's save before click button.
How to do it to save after click button view ?
Best regards
public void savewebpage(AxSHDocVw.AxWebBrowser axWebBrowser1,string strfile)
{
IHTMLDocument2 doc = (IHTMLDocument2) axWebBrowser1.Document;
UCOMIPersistFile pf = (UCOMIPersistFile) doc;
pf.Save(@strfile,true);
}
public void GetMainPage(AxSHDocVw.AxWebBrowser axWebBrowser1,
ref string strfile,string htmlpath)
{
System.Object nullObject = 0;
string str = "";
System.Object nullObjStr = str;
axWebBrowser1.Navigate("http://racing.ustrotting.com/entries.cfm",
ref nullObject, ref nullObjStr,ref nullObjStr, ref nullObjStr);
while (axWebBrowser1.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
{
Application.DoEvents();
}
switch(Task)
{
case 1:
HTMLDocument myDoc = new HTMLDocumentClass();
myDoc = (HTMLDocument) axWebBrowser1.Document;
HTMLInputElement btnView =
(HTMLInputElement) myDoc.all.item("Submit", 0);
btnView.click();
Task++;
break;
case 2:
break;
}
savewebpage(axWebBrowser1,"c:\\myWeb.html");
}
Best regards
tery
|
|
|
|
|
Hi,
I have two files one containing Multiple JPEGs (one after another in single file) when i view the file in picture box, only one jpeg is shown
in another file i have size for each image, i can parse this file and get size and location of any jpeg in that file
can anyone tell me how to get jpeg stored in a file when i know its location in that file and size
Regards,
Arus
|
|
|
|
|
arusmemon wrote:
when i view the file in picture box, only one jpeg is shown
That's all the picture box does.
arusmemon wrote:
can anyone tell me how to get jpeg stored in a file when i know its location in that file and size
You can probably read the jpeg that you want and pass the stream into a constructor.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i have a very long text in one line... more than 1000 words...
my problem is...
i want to divide the whole line into a few lines...
a line can contain only 1033 character (including white space)...
and also... each line must have a header...
after dividing the line... then save it into a file...
my code doesnt work...
here is the method...
<br />
public void SaveCaptured(string savingFile,int count)<br />
{<br />
string fileName = countFileName.ToString() + ".rtf";<br />
<br />
StreamWriter sx = File.CreateText(fileName);<br />
DateTime myDate;<br />
myDate = DateTime.Now;<br />
string myTime = myDate.ToString("yyyyMMddHHmmff");<br />
string lining;<br />
<br />
int totalLine = count%1033;<br />
MessageBox.Show("count%1033 = " + totalLine);<br />
<br />
for(int i=1; i<=totalLine;i++)<br />
{<br />
<br />
sx.Write("189000000000000000000023 000" + myTime + "000 01033 OBFT00xx x 30UG ");<br />
for(int j=0;j<1033;j++)<br />
{ <br />
lining = savingFile.Substring(j,1); <br />
sx.Write(lining);<br />
}<br />
sx.Write("\n");<br />
}<br />
<br />
sx.Flush();<br />
sx.Close();<br />
<br />
return;<br />
}<br />
anybody can help me refining my code??
thanx in advance...
=^_^=
|
|
|
|
|
% is the modulo operator. That means that totalLine will not at all contain the number of lines, but the number of characters on the last line.
As you don't remove the first 1033 characters from the string, you will be looping out the same characters time after time.
Try something more along this:
while (count > 1033) {<br />
sx.Write("189000000000000000000023 000" + myTime + "000 01033 OBFT00xx x 30UG ");<br />
sx.Write(savingFile.Substring(0,1033));<br />
savingFile = savingFile.Substring(1033);<br />
count -= 1033;<br />
}<br />
sx.Write("189000000000000000000023 000" + myTime + "000 01033 OBFT00xx x 30UG ");<br />
sx.Write(savingFile);
---
b { font-weight: normal; }
|
|
|
|
|
mmm... tnx for ur comment...
i know there's something wrong in my logic... 0_o
but i've tried ur code...
still it doesnt add new line..o_0
huhuhu... anyways... tnx..
since i'm a newbie in this field...
at least i have something to start with...
=^_^=
|
|
|
|
|
while (count > 1033) {
sx.Write("189000000000000000000023 000" + myTime + "000 01033 OBFT00xx x 30UG ");
sx.Write(savingFile.Substring(0,1033));
sx.Write("@ \n");
savingFile = savingFile.Substring(1033);
count -= 1033;
}
sx.Write("189000000000000000000023 000" + myTime + "000 01033 OBFT00xx x 30UG ");
sx.Write(savingFile);
just add one more line and it works...
but it save the characters directly...
i mean... it cut in the middle of a string...
eg: per //line 1
cent //line 2 <--continue from line 1...
issit posibble to make it recognize whether it is a whole string or not??
=^_^=
|
|
|
|
|
Of course it is possible.
Use the LastIndexOf method to search for the first space before the last possible split point.
I use the same method here:
http://www.guffa.com/Programming_archive.asp?id=42
---
b { font-weight: normal; }
|
|
|
|
|
thanks a lot man...
u really help me...
=^_^=
|
|
|
|
|
i write a class UserInfo included some fields and property,
and then add method GetUserInfo() in .asmx return type is UserInfo,
but when i call GetUserInfo() from client VS shows error :
can not convert “SSIMS_APP.localhost.SecurityCheckInfo” to “SSIMS_Info.SecurityCheckInfo”
SSIMS_APP is client project
SSIMS_Info is the project Class UserInfo in
|
|
|
|
|
You need to send the parts of the app individually, or create this shared class in a dll that both projects use, so their type is the same.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi all.
iam developing webchat application that hosted on the internet explorer when first tested it it gets to me an exception of type security namespace but i solved that probelm by adding permissions in my dot net configuration manager in my control panel ok and that exception i overcome it successfully but when i ran my server that listens to my port 5151 and ran my internet explorer it takes alot of time to connect to the server and then the client connected and disconnected immediately without anything or any reason i don't know why any help about what is the probable reason for that ?
Miss With The Best And Die Like The Rest
|
|
|
|
|
If you use punctuation, it might be possible to understand what you are writing...
---
b { font-weight: normal; }
|
|
|
|
|
hi,
anyone noes how can i display/pop-up a form IN a tab page? instead of simply typing
form2 frm = new form2();
frm.Show();
wat codes do i write to tell the program to display the form at a certain place such as in a tabpage for my app?
thanks..
|
|
|
|