|
Hey all,
Is there a way to upload an xml document to a script that can then use it as xml and parse it.
I created a php script that will take an xml file off the server, and parse it the way I want, however I do not want to write the file to the server first, I want it to just take the uploaded xml document and begin parsing it.
here's the current uploader that i was using for just string data:
visual basic code:--------------------------------------------------------------------------------
Public Function PostToWebUpdate(ByVal postData) As Boolean
Dim Client As WebClient
Try
Dim dataBytes As Byte() = Encoding.ASCII.GetBytes(postData)
Client = New WebClient
Client.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Dim returnedBytes As Byte() = Client.UploadData("http://www.1483online.com/sciptThatIwant", dataBytes)
Dim myResponse As String = New String(Encoding.ASCII.GetChars(returnedBytes))
Return myResponse = "SAVED"
Catch ex As Exception
MessageBox.Show("Error: PostToWeb: " & ex.Message)
Return False
Finally
Client.Dispose()
Client = Nothing
End Try
End Function--------------------------------------------------------------------------------
However, would this be a parsable xml file or some other thing that I have to convert to xml?
I'm thinking that I cannot use the above post code. I used to have to write a string like this:
game=12&turn=18&unit=Infantry........
Then, I pulled in the variables using php's $HTTP_POST_VARS['game'] (which would return 12). However, I do not know what the $HTTP_POST_VARS['thisvariablename'] would be. Any ideas?
Thanks,
Mike
Gaming at the GuildofBlades.com is the only way to really experiece the level 99 Soul-Sucking Sword!
|
|
|
|
|
As the data that you post doesn't follow the format that you specified (urlencoded), you can not read the request using $HTTP_POST_VARS['anything'].
You have to read the entire request stream as binary data. In ASP and ASP.NET this is done using the BinaryRead method, but how that is done in PHP I have no idea.
---
b { font-weight: normal; }
|
|
|
|
|
is there a way to alter the format to make it readable by grabbing the post data? (what would that be ;-D)
Thanks
Gaming at the GuildofBlades.com is the only way to really experiece the level 99 Soul-Sucking Sword!
|
|
|
|
|
Then you would put the xml document as a posted value by url encoding it, so that the data that you post looks something like this:
doc=%3C%3Fxml+version%3D%221.0%22%3F%3E%0D%0A%3C...
---
b { font-weight: normal; }
|
|
|
|
|
could you please give an example, I'm not following very well. :-/ The only thing that I saw for urlencoding was in an httputility but I couldn't use it for some reason (maybe referencing).
If I have this (a very basic xml file):
Dim XMLDoc As New XmlDocument
Dim xNodeList As XmlNodeList
Dim xNode As XmlNode
XMLDoc.LoadXml("<units>")
Dim info As XmlElement = XMLDoc.CreateElement("info")
info.SetAttribute("attacker", "greek")
XMLDoc.DocumentElement.AppendChild(info)
What do I do to the newly created XmlDocument to get it posted and encoded correctly?
Also, what is the referencing post name?
Thanks,
Mike
Gaming at the GuildofBlades.com is the only way to really experiece the level 99 Soul-Sucking Sword!
|
|
|
|
|
Get the xml document as a string, and use HttpUtility.UrlEncode on it. Use the string as a value in the post data, e.g. "doc=" + xml .
---
b { font-weight: normal; }
|
|
|
|
|
hi all..
i have a problem.. how can i send several data in one time using mscomm1..
can someone please help me..
thanks..
areon25
|
|
|
|
|
Send several data? You can only send one piece of information at a time. You'll have to explain what you mean by "send several data in one time".
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hi all..
thanks dave.. ok.. i'll explain what i whant to do..
actually, i want to make a project using vb. i want to make some interface in vb to my hardware using MSCOMM.. actually, about the hardware, i want to control motor.. but for this moment i want to learn simple application, for example i want to turn on LED( the hardware ) from the interface(VB).
for your information.. i use PIC16F877A and microC software(from microelektronika) to program the PIC16F877A.. and i use rs232 protocol
for this moment i want to send data from vb using MSCOMM to turn on the LED..
for example, in my vb there are two command button, button1 and button2.. button1 is for turn on the LED1 and button2 is to turn on the LED2..
does someone know how to do it.. can someone please help me..
areon25
|
|
|
|
|
First, which version of VB are you using?? VB6, VB.NET 2002, 2003, or 2005?
Now, those are two entirely seperate projects that don't have anything to do with each other...
The first one, programming a controller over serial, is easy enough to do. All you have to do is setup the COMM port with the correct parameters and start sending and receiving data, just like you type it in HyperTerminal. The exact procedure for which is dependant on your controller requirements. You can find example projects all over the 'Net, just Google for "VB Serial Comm".
The LED one isn't so easy. The serial port isn't normally used for this because of its low pin count and the programmability of the port only gives you a brief "ON" for the LED, unless you continuously send data to the port. The parallel port is customarilly used for LEDs, switches, and stepper motors. Again, just Google for "VB control LED" and you'll find a few projects, but on the parallel port.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hi all..
thanks dave for replying my msg..
for your in formation i use vb 6.0..
areon25
|
|
|
|
|
Hello, I'm sorry for asking such a basic question but I cannot find the answer to it by searching any forums..
All I need is to be able to do something simple like make a msbgox pop up when the user clicks enter on a text box. Basically a user will type a number in the textbox and then a pop up box will appear showing the number they have just typed.
Could someone help me with this please?
Thanks
John C
|
|
|
|
|
There are several possible ways to do this, depending on your needs. You could use the "Leave" event of the textbox to popup your messagebox when the control loses focus (either by pressing enter, tab, or clicking the mouse on another control).
If you only want the popup to occur when the enter key is pressed, you should use the textbox control's "Keypress" event to check whether the key pressed was the return key, and run your popup code if it was.
Hope this helps.
|
|
|
|
|
Hi,
I think the following code will fulfill your requirement.
TextBox1_KeyPress
-----------------
If Asc(e.KeyChar) = 13 Then
MsgBox("The Data You Have Entered : " & TextBox1.Text, MsgBoxStyle.Information)
End If
With Regards,
Pandian S
|
|
|
|
|
iam working in vb.net 2003 the default datetime format is 'mdy' when i try to store datetime in database in format 'dmy' error apear i want to store datetime n database in format 'dmy' and when reterive and dir in application dir it in format 'dmy'
ma_refay
|
|
|
|
|
That is impossible. You can not store a date in a specific format, as a date field doesn't have a format.
Specify the format to use when you convert the date into a string for displaying.
Example for ISO 8601 standard format:
lblDate.Text = reader.GetDateTime("mydate").ToString("yyyy-MM-dd")
---
b { font-weight: normal; }
|
|
|
|
|
If you use myTextBox.Text.ToLongDateString() the return value will always be in the format of the current culture of the machine (regional settings) or that has been set in your app.
Other methods are:
.ToShortDateString()
.ToLongTimeString()
.ToShortTimeString()
etc...
Steve
|
|
|
|
|
I need to clear my visible tables and reload them regularly. When I use tableadapter.clear, however, the daa table completely disappears and then is redrawn with the new data. This is annoying! Can I clear and refill a table in another way that doesn't do this?
Thanks!
|
|
|
|
|
If you are loading data into your dataset using a Fill method, you can set the ClearBeforeFill property of the tableadapter to true. This will prevent you from having to explicitly call the clear method. I have not tested this, so I am not sure if the control will redraw the way you would like, but it's worth a shot.
Another possibility would be to call the SuspendLayout method on the control prior to calling clear, then call resumelayout after the table is reloaded. Again, I have not tested this option either but I believe it will suspend redrawing of the control until ResumeLayout is called.
|
|
|
|
|
I have attached the database programmatically in 2003 by running the sp_attach_db function on sql.
But when i try to do tha same in 2005 then the problem is is says
"Cannot associate files with different databases."
this is when i try to add both MDF and LDF files.
Can any when tell me how can i attach database progmt in 2005
|
|
|
|
|
Hi Everyone,
How to uninstall specific program from the control panel/ Add remove programs using vb6. Can anyone help me in this regard.
Thanks in Advance,
Regards,
Manowj
|
|
|
|
|
I am making an eyedropper tool for my program and want to use GetPixel. The problem is everytime i call the getpixel function, it only seems to see the pixels of my form's backcolour and clicks right through my picture box.
Can anyone suggest a reason and/or solution for this problem, or even an alternative more effective method.
this is my code:
Dim EyeD as boolean = true
Private Function GetPixel(ByVal x As Integer, ByVal y As Integer) As Color
End Function
Private Sub ButtonEyeDropper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EyeDropper.Click
EyeD = True
End Sub
rivate Sub PictureBoxDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Display.Click
If Me.EyeD = True Then
PixelColour = GetPixel(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y)
Me.panColour.BackColor = PixelColour
Dim strImage As Bitmap = Display.Image
strImage.MakeTransparent(PixelColour)
Me.Display.Image = strImage
EyeD = False
Else
If Keys.RButton Then
Me.Display.SizeMode = PictureBoxSizeMode.Zoom
End If
End If
End Sub
Posted by The ANZAC
|
|
|
|
|
You managed to show all the code except the code where the problem is. What does your GetPixel function contain?
---
b { font-weight: normal; }
|
|
|
|
|
How about:
Dim c As Color
c = PictureBox1.Image.GetPixel(PictureBox1.PointToClient(Windows.Forms.Cursor.Position))
This should work, so long as the Image property of the PictureBox returns a Bitmap object.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
When i put this code in, i get a message that says "GetPixel is not a member of system.Drawing.Image"
where am i supposed to put this code anyhow, you were a bit vague on that matter.
Posted by The ANZAC
|
|
|
|