Link to home
Start Free TrialLog in
Avatar of prowebinteractiveinc
prowebinteractiveinc

asked on

php simplexml_load_string($data) problem

I am sending the Mac Address of a logger to an application connected to my mySQL database.
it appears that the "%" in the mac address is considered an invalid char. I was wondering if there is a fix to this issue.

fe80::25ea:dfaa:bdd0:32f%11  (Suppose to be)
fe80::25ea:dfaa:bdd0:32f         (What is displayed while debugging)
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Where is VB.NET involved in that?
I am not seeing a problem.
http://www.laprbass.com/RAY_temp_prowebinteractive.php
<?php // RAY_temp_prowebinteractive.php
error_reporting(E_ALL);

$xml = <<<XML
<thing>
  <field>fe80::25ea:dfaa:bdd0:32f%11</field>
</thing>
XML;

$obj = simpleXML_load_string($xml);

var_dump($obj);

Open in new window

Perhaps you're looking at the browser-rendered HTML?  If so, you will see the entity created by %11.  I do not know what that might encode, but I expect it is down in the control characters and possibly invisible.
Avatar of prowebinteractiveinc
prowebinteractiveinc

ASKER

not looking at it in a browser, the only issue would have to be in the VB.NET when POSTING
here is my code:

Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Public Class logVbUser
    Public Shared responseFromVbLogger As String
    Public Shared Sub Main(ByVal customerId As Integer, ByVal userId As Integer, ByVal pcName As String, ByVal macAddress As String)
        MessageBox.Show(macAddress)
        Dim xml As String
        xml = "logRequestMode=X&logRequestData="
        xml += "<?xml version='1.0' encoding='UTF-8'?>"
        xml += "<TranxRequest>"
        xml += "<CompanyId>" & customerId & "</CompanyId>"
        xml += "<UserId>" & userId & "</UserId>"
        xml += "<pcName>" & pcName & "</pcName>"
        xml += "<macAddress>" & macAddress & "</xxxName>"
        xml += "</TranxRequest>"

        'Form2.Label20.Text = xml
        ' Create a request using a URL that can receive a post. 
        Dim request As WebRequest = WebRequest.Create("http://" & databaseConnection.dbServer & "/includes/vbNetLogger.php")
        ' Set the Method property of the request to POST.
        request.Method = "POST"
        ' Create POST data and convert it to a byte array.
        Dim postData As String = xml
        Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
        ' Set the ContentType property of the WebRequest.
        request.ContentType = "application/x-www-form-urlencoded"
        ' Set the ContentLength property of the WebRequest.
        request.ContentLength = byteArray.Length
        ' Get the request stream.
        Dim dataStream As Stream = request.GetRequestStream()
        ' Write the data to the request stream.
        dataStream.Write(byteArray, 0, byteArray.Length)
        ' Close the Stream object.
        dataStream.Close()
        ' Get the response.
        Dim response As WebResponse = request.GetResponse()
        ' Display the status.
        Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
        ' Get the stream containing content returned by the server.
        dataStream = response.GetResponseStream()
        ' Open the stream using a StreamReader for easy access.
        Dim reader As New StreamReader(dataStream)
        ' Read the content.
        Dim responseFromServer As String = reader.ReadToEnd()
        ' Display the content.
        responseFromVbLogger = responseFromServer
        Console.WriteLine(responseFromServer)
        ' Clean up the streams.
        reader.Close()
        dataStream.Close()
        response.Close()
    End Sub
End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial