• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 520
  • Last Modified:

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)
0
prowebinteractiveinc
Asked:
prowebinteractiveinc
  • 2
1 Solution
 
CodeCruiserCommented:
Where is VB.NET involved in that?
0
 
Ray PaseurCommented:
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.
0
 
prowebinteractiveincAuthor Commented:
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

0
 
Ray PaseurCommented:
Line 16 appears to be invalid XML:

xml += "<macAddress>" & macAddress & "</xxxName>"

Not sure if this is related to the issue, but it appears to be odd.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now